You can edit the contents of the pink textareas below.
Put a regular expression in a search pattern box, and a replacement pattern in the corresponding replacement pattern box. The search pattern will be matched against whatever you type into the input textarea, and the result of filling in the template will appear in the output textarea. Each (pattern/replacement) pair is applied in turn, so order is important.
search pattern (regular expression) | replacement pattern (template) |
---|---|
input text | output text |
http://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/RegExp
The replacement string can include the following special replacement patterns:
Pattern | Inserts |
---|---|
$$
|
Inserts a "$". |
$&
|
Inserts the matched substring. |
$`
|
Inserts the portion of the string that precedes the matched substring. |
$'
|
Inserts the portion of the string that follows the matched substring. |
$n
or
$nn
|
Where
n
or
nn
are decimal digits, inserts the nth parenthesized submatch string.
|
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 |
. |
(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, |
{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, |
\d |
Matches a digit character in the basic Latin alphabet. Equivalent to For example, |
\D |
Matches any non-digit character in the basic Latin alphabet. Equivalent to For example, |
\n |
Matches a linefeed. |
\s |
Matches a single white space character, including space, tab, form feed, line feed and other unicode spaces. For example, |
\S |
Matches a single character other than white space. For example, |
\t |
Matches a tab. |
\w |
Matches any alphanumeric character from the basic Latin alphabet, including the underscore. Equivalent to For example, |
\W |
Matches any character that is not a word character from the basic Latin alphabet. Equivalent to For example, |