Class: NamedRegExp

NamedRegExp

new NamedRegExp(regexp, flagsopt, nullable)

Constructs a NamedRegExp object
Parameters:
Name Type Attributes Default Description
regexp String a string describing a regular expression. All backslashes must be escaped, e.g. \\d
flags String <optional>
<nullable>
"" a string of regexp flags, e.g. "mi" for multiline case-insensitive
Source:

Methods

exec(string) → {Array.<String>}

Extension of RegExp.exec() Returns an extended array - first array element is matching string, and elements thereafter are captured strings from regular (non-named) groups. Named captures are extend upon arrays, e.g. for a name of "date" the array will contain a property "date" with the captured string.

Multiple matches behave like RegExp.exec(), where each iteration of the call produces the next match, or null if there are no more matches.

If there is no match for the regular expression, null is returned.

Parameters:
Name Type Description
string String test string
Source:
Returns:
array of match & captured matches, extended with named capture groups as object properties. See documentation for js's built in regex for more information
Type
Array.<String>

getNames() → {Array.<String>}

Gets array of capture group labels
Source:
Returns:
Capture group labels
Type
Array.<String>

test(string) → {Boolean}

Tests for a match, just like RegExp.test()
Parameters:
Name Type Description
string String test string
Source:
Returns:
whether a match was found or not
Type
Boolean