ret-extended
Overview
This adds details to the tokens produced by the ret package. Namely it adds the following properties.
For all tokens the following properties are given:
/**
* Details that are added to every ret.js token
*/
export interface Detailed<T extends Tokens> {
/**
* Minimum number of characters required to 'satisfy' the regex component
*/
minChar: number;
/**
* Maximum number of characters required to 'satisfy' the regex component
*/
maxChar: number;
/**
* Whether the '^' positional is applied or not;
*/
leftEnd: boolean;
/**
* Whether the '$' positional is applied or not;
*/
rightEnd: boolean;
/**
* The original tokens
*/
token: T
/**
* Regular expression (Regex Object with flags) that the token is representing
*/
regex: RegExp;
/**
* Generator for possible values of regular expression
*/
pattern?: string[];
/**
* Whether this token has a 'fixed solution', e.g `(hello)`,
* or many solutions, e.g. `[0-9]`.
*/
fixed: boolean;
}
In addition, remembered capturing groups are given a reference
entry which is the value that backreferences should use to refer to that group.
Usage
import { regexDetailTokenizer } from '../lib';
regexDetailTokenizer(/a-z/i) // Outputs detailed tokens
License
©2021–present Jesse Wright, MIT License.