strscanner
lexical string analysis for javascript
Last updated 12 years ago by architectd .
Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install strscanner 
SYNC missed versions from official npm registry.

Example


var strscan = require("strscan");

var scanner = strscan("hello world -> ", {
	skipWhitespace: true
});


while(!scanner.eof()) {
	
	scanner.nextChar();

	if(scanner.isAZ()) {
		var word = scanner.nextWord();
	} else 
	if(scanner.cchar() == "-") {
		var arrow = scanner.to(1);
	}
}

API

.eof()

returns true if the scanner is at the end

.nextChar()

scans to the next character

.cchar()

returns the current char

.isAZ()

returns true if the current char is A-Z

.is09()

returns true if the current char is 0-9

.isAlpha()

returns true if the current char is A-Z 0-9

.next(match)

returns true if the current char matches the given regular expression

.nextWord()

returns the next word

.to(count)

scans to the given position, and returns the buffer

.peek(count)

returns a buffer from the current position to the given count, then rewinds

.rewind(count)

rewinds N characters

.skip(count)

skips N characters

Current Tags

  • 0.0.8                                ...           latest (12 years ago)

8 Versions

  • 0.0.8                                ...           12 years ago
  • 0.0.6                                ...           12 years ago
  • 0.0.5                                ...           13 years ago
  • 0.0.4                                ...           13 years ago
  • 0.0.3                                ...           13 years ago
  • 0.0.2                                ...           13 years ago
  • 0.0.1                                ...           14 years ago
  • 0.0.0                                ...           14 years ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (0)
None
Dev Dependencies (0)
None
Dependents (2)

Copyright 2013 - present © cnpmjs.org | Home |