# strscan

> Simple string tokenizer for lexical scanning operations

Latest version **1.0.1** (published 2015-01-01) · 0 weekly downloads

## Install

```sh
npm install strscan
pnpm add strscan
yarn add strscan
bun add strscan
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2015-01-01 |
| First published | 2015-01-01 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | * |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Sam Stephenson |

## Links

- npm: https://www.npmjs.com/package/strscan
- Repository: http://github.com/sstephenson/strscan-js
- npm.io page: https://npm.io/package/strscan

## Recent versions

- 1.0.1 (latest) — 2015-01-01
- 1.0.0 — 2015-01-01

## README

## StringScanner

**StringScanner** is a simple string tokenizer that provides for lexical
scanning operations on a string. It's a JavaScript port of the [Ruby 
library with the same name](http://ruby-doc.org/core/classes/StringScanner.html).

Scanning a string means keeping track of and advancing a position (a
zero-based index into the source string) and matching regular expressions
against the portion of the source string after the position.

StringScanner is written in [CoffeeScript](http://coffeescript.org/) and
distributed via [npm](http://npm.mape.me/) as a [CommonJS 
module](http://www.commonjs.org/).

### Quick start

    $ npm install strscan
    $ node-repl
    > var StringScanner = require("strscan").StringScanner
    > var s = new StringScanner("This is a test")
    > s.scan(/\w+/)             # => "This"
    > s.scan(/\w+/)             # => null
    > s.scan(/\s+/)             # => " "
    > s.scan(/\s+/)             # => null
    > s.scan(/\w+/)             # => "is"
    > s.hasTerminated()         # => false
    > s.scan(/\s+/)             # => " "
    > s.scan(/(\w+)\s+(\w+)/)   # => "a test"
    > s.getMatch()              # => "a test"
    > s.getCapture(0)           # => "a"
    > s.getCapture(1)           # => "test"
    > s.hasTerminated()         # => true

### More

[Clone, fork, or file bugs at GitHub](http://github.com/sstephenson/strscan-js)

[Read the full documentation/annotated source code](http://sstephenson.github.com/strscan-js/)

### Copyright

Copyright (c) 2010 Sam Stephenson. Distributed under the terms of an
MIT-style license. See LICENSE for details.

---
_Source: https://npm.io/package/strscan · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
