|
2 anos atrás | |
---|---|---|
.. | ||
lib | 2 anos atrás | |
CHANGELOG.md | 2 anos atrás | |
LICENSE | 2 anos atrás | |
README.md | 2 anos atrás | |
package.json | 2 anos atrás |
utilities for generating regular expression
# using npm
npm install --save regexp-util
# using yarn
yarn add regexp-util
const util = require('regexp-util');
const regex = util.charset(['a', 'g']) // a ~ g
.subtract(['c', 'e'])
.toRegExp();
const aResult = 'a'.test(regex); //=> true
const dResult = 'd'.test(regex); //=> false
declare abstract class Base {
isEmpty(): boolean;
toString(): string;
toRegExp(flags?: string): RegExp;
}
declare type CharsetInput =
| Charset
| string // char
| number // codepoint
| [string, string] // char: start to end (inclusive)
| [number, number]; // codepoint: start to end (inclusive)
declare const charset: (...inputs: CharsetInput[]) => Charset;
declare class Charset extends Base {
constructor(...inputs: CharsetInput[]);
union(...inputs: CharsetInput[]): Charset;
subtract(...inputs: CharsetInput[]): Charset;
intersect(...inputs: CharsetInput[]): Charset;
}
# lint
yarn run lint
# build
yarn run build
# test
yarn run test
MIT © Ika