JSVerbalExpressions Docs

API Documentation for JSVerbalExpressions.

View the Project on GitHub
VerbalExpressions/JSVerbalExpressions


VerExVerbalExpression


Special Characters

lineBreak

Match a line break (both Unix style and Windows style).

const expr = VerEx().find('foo').lineBreak().then('bar');
console.log(expr.test('foo\nbar'));

br

An alias for lineBreak.

tab

Match a tab character.

const tabs = VerEx().tab();
const code = '\tconsole.log("tabs vs spaces")';

// => '    console.log("tabs vs spaces")'
console.log(tabs.replace(code, '    '));

word

Match a word—a string of word characters (a–z, A–Z, 0–9 or _).

const word = VerEx().startOfLine().word().endOfLine();

console.log(word.test('foo')); // => true
word.lastIndex = 0;
console.log(word.test('foo-bar')); // => false

digit

Match a digit (0–9).

const digit = VerEx().digit();
console.log(digit.test('2')); // => true

whitespace

Match a whitespace character (one of space, tab, carriage return, new line, vertical tab and form feed).

const expr = VerEx().word().whitespace().word();
console.log(expr.test('word\tword')); // => true