Represents compiled regular expresion.
RE Syntax supported:
| Character | Meaning |
\ |
For characters that are usually treated literally, indicates that the next character is special and not to be interpreted literally. For example, or For characters that are usually treated specially, indicates that the next character is not special and should be interpreted literally. For example, * is a special character that means 0 or more occurrences of the preceding character should be matched; for example, |
^ |
Matches beginning of input. If the multiline flag is set to true, also matches immediately after a line break character. For example, |
$ |
Matches end of input. If the multiline flag is set to true, also matches immediately before a line break character. For example, |
* |
Matches the preceding item 0 or more times. For example, |
+ |
Matches the preceding item 1 or more times. Equivalent to For example, |
? |
Matches the preceding item 0 or 1 time. For example, If used immediately after any of the quantifiers Also used in lookahead assertions, described under |
. |
(The decimal point) matches any single character except the newline characters: \n \r \u2028 or \u2029. ( For example, |
(x) |
Matches For example, |
x|y |
Matches either For example, |
\b |
Matches a word boundary, such as a space. (Not to be confused with For example, |
\B |
Matches a non-word boundary. For example, |
\d |
Matches a digit character from any alphabet. For example, |
\D |
Matches any non-digit character in any alphabet. For example, |
\m |
Matches any alpha or numeric character from any alphabet. |
\M |
Matches any non-alpha and non-numeric character from any alphabet. |
\a |
Matches any alpha character from any alphabet. |
\A |
Matches any non-alpha character from any alphabet. |
\c |
Matches any control character from any alphabet. |
\C |
Matches any non-control character from any alphabet. |
\g |
Matches any character that has graphic representation from any alphabet. |
\G |
Matches any character that has no graphic representation from any alphabet. |
\p |
Matches any printable or space character from any alphabet. |
\P |
Matches any non-printable and non-space character from any alphabet. |
\l |
Matches any lower case character from any alphabet. |
\L |
Matches any non-lower case character from any alphabet. |
\u |
Matches any upper case character from any alphabet. |
\U |
Matches any non-upper case character from any alphabet. |
\n |
Matches any punctuation character from any alphabet. |
\N |
Matches any non-punctuation character from any alphabet. |
\s |
Matches any space character from any alphabet. |
\S |
Matches any non-space character from any alphabet. |
\x |
Matches any hexadecimal character. |
\X |
Matches any non-hexadecimal character. |
Properties | |
| length | - integer, number of matches after last exec or match methods calls. |
| input | - string, last inspected string. |
| source | - string, source code of the regular expression - string this RegExp was build from. |
| index | - integer, character position where the first successful match begins in a searched string, read-only. |
| lastIndex | - integer, character position where the next match begins in a searched string. |
| [index] | - string | undefined, read-only, returns n-th matched fragment. Index is a zero based index, integer. |
Methods | |
| this |
(regular-expresion [,flags]) Used for intitalization of new instance of RegExp object. regular-expresion is a string - source of the regular expression. flags is an optional string and if provided may contain characters 'i' for case insensitive search and/or 'g' - for global search - to find all occurences of source in the input string. |
| test |
(input) : true | false Checks input string to see if a pattern exists within a string and returns true if so, and false otherwise. |
| exec |
(input) : null | RegExp object Returns this RegExp object with length and list of matches set if pattern exists in input string or null otherwise. |