Defining Patterns : Introduction : Regular Expressions JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Regular Expressions » Introduction »

 

Defining Patterns








There are special characters for creating almost any pattern.

Special Pattern Matching Characters











































































































Character Description
w Matches any word character (alphanumeric).
W Matches any non-word character.
s Matches any whitespace character (tab, newline, carriage return, form feed, vertical tab).
S Matches any non-whitespace character.
d Matches any numerical digit.
D Matches any character that is not a number.
[b] Matches a backspace.
. Matches any character except a newline.
[...] Matches any one character within the brackets.
[^...] Matches any one character not within the brackets.
[x-y] Matches any character in the range of x to y.
[^x-y] Matches any character not in the range of x to y.
{x,y} Matches the previous item at least x times but not to exceed y times.
{x,} Matches the previous item at least x times.
{x} Matches the previous item exactly x times.
? Matches the previous item once or not at all.
+ Matches the previous item at least once.
* Matches the previous item any number of times or not at all.
| Matches the expression to the left or the right of the | character.
(...) Group everything inside parentheses into a subpattern.
x Matches the same characters that resulted from the subpattern in group number x. Groups, which are designated with parentheses, are numbered from left to right.
^ Matches the beginning of the string or beginning of a line, in multiline matches.
$ Matches the end of the string or end of a line, in multiline matches.
b Matches the position between a word character and a non-word character.
B Matches the position that is not between a word character and a non-word character.








HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Regular Expressions
» Introduction