Regular Expression Calculator
This is a simple JavaScript-based RegExp validator. It simply states the number of times the patern (regexp) matches the text supplied.
Regular Expression Example 1The RegExp:
will match the following text once:
Click here to load this example into the RegExp validator. |
Regular Expression Example 2The RegExp:
will match the following text twice:
Click here to load this example into the RegExp validator. |
See the special character meanings below for an explanation of the above.
RegExp Calculator
This RegExp validator should work with regular expressions in all the common languages such as perl, javascript, .Net, PHP etc.
Special characters in regular expressions.
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, |
^ | Matches beginning of input or line.
For example, |
$ | Matches end of input or line.
For example, |
* | Matches the preceding character 0 or more times.
For example, |
+ |
Matches the preceding character 1 or more times. Equivalent to
For example, |
? | Matches the preceding character 0 or 1 time.
For example, |
. | (The decimal point) matches any single character except the newline character.
For example, |
(x) | Matches 'x' and remembers the match.
For example, |
x|y | Matches either 'x' or 'y'.
For example, |
{n} |
Where
For example, |
{n,} |
Where
For example, |
{n,m} |
Where
For example, |
[xyz] | A character set. Matches any one of the enclosed characters. You can specify a range of characters by using a hyphen.
For example, |
[^xyz] | A negated or complemented character set. That is, it matches anything that is not enclosed in the brackets. You can specify a range of characters by using a hyphen.
For example, |
[\b] |
Matches a backspace. (Not to be confused with |
\b |
Matches a word boundary, such as a space. (Not to be confused with
For example, |
\B | Matches a non-word boundary.
For example, |
\cX | Where X is a control character. Matches a control character in a string.
For example, |
\d |
Matches a digit character. Equivalent to
For example, |
\D |
Matches any non-digit character. Equivalent to
For example, |
\f | Matches a form-feed. |
\n | Matches a linefeed. |
\r | Matches a carriage return. |
\s |
Matches a single white space character, including space, tab, form feed, line feed. Equivalent to
for example, |
\S |
Matches a single character other than white space. Equivalent to
For example, |
\t | Matches a tab |
\v | Matches a vertical tab. |
\w |
Matches any alphanumeric character including the underscore. Equivalent to
For example, |
\W |
Matches any non-word character. Equivalent to
For example, |
\n | Where n is a positive integer. A back reference to the last substring matching the n parenthetical in the regular expression (counting left parentheses).
For example, Note: If the number of left parentheses is less than the number specified in \n, the \n is taken as an octal escape as described in the next row. |
\ooctal |
Where |
This table has been copied from Netscape DevEdge Client-Side JavaScript Reference