Regular Expression Syntax
-
About Regular Expressions
Regular Expressions (regex) are character-matching patterns that are used to find and/or replace character patterns in strings.With Regular Expression...
-
Regular Expression Syntax
A Regular Expression is a pattern of text that consists of ordinary characters (for example, letters a through z) and special characters, known as met...
-
Ordinary Characters
Ordinary characters consist of all characters that are not explicitly designated as meta characters. This includes:all upper- and lowercase alphabetic charac...
-
Special Characters
There are a number of meta characters that require special treatment when trying to match them. To match these special characters, you must first escape them...
-
Non-Printable Characters
A number of useful non-printing characters are occasionally used. The table below shows the escape sequences used to represent those non-printing characters:...
-
Bracket Expressions
Many times it's useful to match specified characters from a list. For example, you may want to search a string for chapter headings that are expressed as Cha...
-
Quantifiers
Sometimes, you don't know how many characters there are to match. In order to accommodate that kind of uncertainty, Regular Expressions support the concept o...
-
Anchors
All the examples so far have recognized patterns anywhere in a string. But you may want the patterns to match only if they, for example, appear at the beginn...
-
Alternation and Grouping
Alternation allows use of the | (pipe) character to allow a choice between two or more alternatives, a bit similar to or in Boolean expressions. Expan...
-
Back-References
You can store a part of a matched pattern for later reuse. Placing parentheses around a Regular Expression pattern or part of a pattern causes that pa...
-
Digits and Word Characters
CharacterDescription\d Matches a digit character. Equivalent to [0-9]. \D Matches a non-digit character. Equivalent to [^0-9]. \w ...
-
Hexadecimal and Octal Escape Values and Unicode Characters
Character Description \xn Matches n, where n is a hexadecimal escape value. Hexadecimal escape values must be exactly two digits long. For...
-
Order of Precedence
Once you have constructed a Regular Expression, it is evaluated much like an arithmetic expression, that is, it is evaluated from left to right and follows a...