The following syntax is used to construct regex objects (or assign) that have selected ECMAScript as its grammar.
A regular expression pattern is formed by a sequence of characters.
Regular expression operations look sequentially for matches between the
characters of the pattern and the characters in the target sequence: In
principle, each character in the pattern is matched against the
corresponding character in the target sequence, one by one. But the
regex syntax allows for special characters and expressions in the
pattern:
Special pattern characters
Special pattern characters are characters (or sequences of characters)
that have a special meaning when they appear in a regular expression
pattern, either to represent a character that is difficult to express in
a string, or to represent a category of characters. Each of these special pattern characters is matched in the target sequence against a single character (unless a quantifier specifies otherwise).
characters | description | matches |
---|---|---|
. | not newline | any character except line terminators (LF, CR, LS, PS). |
tab (HT) | a horizontal tab character (same as u0009). | |
newline (LF) | a newline (line feed) character (same as u000A). | |
v | vertical tab (VT) | a vertical tab character (same as u000B). |
f | form feed (FF) | a form feed character (same as u000C). |
carriage return (CR) | a carriage return character (same as u000D). | |
cletter | control code | a control code character whose code unit value is the same as the remainder of dividing the code unit value of letter by 32. For example: ca is the same as u0001, cb the same as u0002, and so on... |
xhh | ASCII character | a character whose code unit value has an hex value equivalent to the two hex digits hh. For example: x4c is the same as L, or x23 the same as #. |
uhhhh | unicode character | a character whose code unit value has an hex value equivalent to the four hex digits hhhh. |