RegExp
Module | ejs |
Definition | final class RegExp |
Inheritance | RegExp Object |
Specified | evolving |
Regular expressions per ECMA-262.
The following special characters are supported:
\\ | Reverse whether a character is treated literally or not. |
^ | Match to the start of input. If multiline, match starting after a line break. |
$ | Match to the end of input. If matching multiline, match before after a line break. |
*< | Match the preceding item zero or more times. |
+ | Match the preceding item one or more times. |
? | Match the preceding item zero or one times. |
(mem) | Match inside the parenthesis (i.e. "mem") and store the match. |
(?:nomem) | Match "nomem" and do not store the match. |
oper(?=need) | Match "oper" only if it is followed by "need". |
oper(?!not) | Match "oper" only if it is not followed by "not". |
either|or | Match "either" or "or". |
{int} | Match exactly int occurences of the preceding item. |
{int,} | Match at least int occurences of the preceding item. |
{int1,int2} | Match at least int1 occurences of the preceding item but no more then int2. |
[pqr] | Match any one of the enclosed characters. Use a hyphen to specify a range of characters. |
[^pqr] | Match anything except the characters in brackets. |
[\b] | Match a backspace. |
\b | Match a word boundary. |
\B | Match a non-word boundary. |
\cQ | Match a control string, e.g. Control-Q |
\d | Match a digit. |
\D | Match any non-digit character. |
\f | Match a form feed. |
\n | Match a line feed. |
\r | Match a carriage return. |
\s | Match a single white space. |
\S | Match a non-white space. |
\t | Match a tab. |
\v | Match a vertical tab. |
\w | Match any alphanumeric character. |
\W | Match any non-word character. |
\int | A reference back int matches. |
\0 | Match a null character. |
\xYY | Match the character code YY. |
\xYYYY | Match the character code YYYY. |
Properties
Qualifiers | Property | Type | Description |
get | global | Boolean | Global flag. If the global modifier was specified, the regular expression will search through the entire
input string looking for matches. |
get | ignoreCase | Boolean | Ignore case flag. If the ignore case modifier was specified, the regular expression is case insensitive. |
get set | lastIndex | Number | The integer index of the end of the last match plus one. This is the index to start the next match for
global patterns. This is only set if the "g" flag was used.
It is set to the match ending index plus one. Set to zero if no match. |
get | matched | String | Substring last matched. Set to the matched string or null if there were no matches. |
get | multiline | Boolean | Multiline flag. If the multiline modifier was specified, the regular expression will search through carriage
return and new line characters in the input. |
get | source | String | Regular expression source pattern currently set. |
get | start | Number | Get the integer index of the start of the last match. This is only set of the "g" global flax is used. |
get | sticky | Boolean | Sticky flag. If the sticky modifier was specified, the regular expression will only match from the lastIndex. |
Inherited Properties
RegExp Class Methods
Qualifiers | Method |
(No own class methods defined)
Inherited Methods
RegExp Instance Methods
Qualifiers | Method |
| RegExp(pattern: String, flags: String = null) |
| Create a regular expression object that can be used to process strings. |
| exec(str: String, start: Number = 0): Array |
| Match this regular expression against the supplied string. |
| replace(str: String, replacement: Object): String |
| Replace all the matches. |
| split(target: String): Array |
| Split the target string into substrings around the matching sections. |
| test(str: String): Boolean |
| Test whether this regular expression will match against a string. |
override | toString(): String |
| Convert the regular expression to a string. |
Inherited Methods
Method Detail
- Description
- Create a regular expression object that can be used to process strings.
- Parameters
pattern: String | The pattern to associated with this regular expression. |
flags: String | "g" for global match, "i" to ignore case, "m" match over multiple lines, "y" for sticky match. "s" so that "." will match all characters. [default: null] |
- Description
- Match this regular expression against the supplied string. By default, the matching starts at the beginning
of the string.
- Parameters
str: String | String to match. |
start: Number | Optional starting index for matching. [default: 0] |
- Returns
- Array of results. The first element is the entire match. Subsequent elements correspond to the matching sub-expressions. Returns null if not match.
- Specified
- ejs Adds start argument.
- Description
- Replace all the matches. This call replaces all matching substrings with the corresponding array element.
If the array element is not a string, it is converted to a string before replacement.
- Parameters
str: String | String to match and replace. |
replacement: Object | Replacement text. This can contain & to insert the matched substring, ` to insert the portion preceeding that matched substring, ' to insert the portion following the matched substring, n where n is the nth parentesized substring or $ to insert a literal character. |
- Returns
- A string with zero, one or more substitutions in it.
- Specified
- ejs
H
- Description
- Split the target string into substrings around the matching sections.
- Parameters
target: String | String to split. |
- Returns
- Array containing the matching substrings.
- Specified
- ejscript-2.5
- Description
- Test whether this regular expression will match against a string.
- Parameters
- Returns
- True if there is a match, false otherwise.
- Specified
- ejs
8
- Description
- Convert the regular expression to a string. This form will wrap the expression with slash delimiters and append the regular expression flags.
For example: "/pattern/g".
- Returns
- A string representation of the regular expression. 8.