Regular expression syntax

Regular expression Description
a a where a is any symbol excluding symbols (|)[].*+^$\?
\a a where a is any symbol including (|)[].*+^$\?

To represent any symbol "as is", prefix it with a backslash symbol. You can use it to represent special characters, including characters inside of CharSet. To represent a single backslash character ( \ ), prefix it with itself ( \\ ).

For example: \* means character "*" and \a means character "a".

. Any single symbol.

For example: expression 11.5 corresponds to such combinations of characters as "1135", "11f5", "11_5" and so on.

RegExp Any regular expression RegExp.

For instance, 112 represents sequence "112", which can be found inside a string (not the whole string!).

RegExp1|RegExp2 Any one of expressions RegExp1 or RegExp2

For example, expression 1|3 validates any of symbols "1" or "3".

Concatenation has priority over alternation. This means that combination 12.5|78 corresponds "(12(any number)5) or (78)". So, the representations of this example can be: "1235", "12f5", "78".
RegExp+ Regular expression RegExp repeated one or more times.

Use this expression to find sequences of desired characters.

For example, (1|3)+ will find expressions (1|3), (1|3)(1|3) and so on.

RegExp* Regular expression RegExp repeated zero or more times.
RegExp? Regular expression RegExp repeated zero or one time.
RegExp1RegExp2 Sequence of two expressions: RegExp1 then RegExp2.

For example, (1|3)(11.5) corresponds to such combinations as "11175", "311t5" and so on.

^ Beginning of string.

Use this symbol to find strings which begin with predefined regular expression. The desired expression must follow ^ sign.

For example:

  • Expression ^1 corresponds to all strings which begin with "1";
  • ^(1|3) - all strings which begin with "1" or "3".
$ End of string.

Use this symbol to find strings which end with predefined regular expression. The desired expression must precede $ sign. Expression ^RegExp$ corresponds to the whole string only.

For example:

  • Expression 5$ corresponds to all strings which end with "5";
  • (1|3)$ - all strings which end with "1” or "3”;
  • ^(a|c)..123.$ represents whole strings which begin with "a" or "c" then have any two characters, then sequence "123" and end with any character: "age123y", "cat1234" and so on.
[CharSet] Any single symbol belonging to a character set CharSet.

The CharSet is specified as a character string and includes all symbols of the string. The order of characters doesn't matter. A "-" sign inside of the CharSet has a special meaning and is used to represent a characters interval.

For example, expression [12a-e34] means the same as [12abcde34], it stands for any character "1", "2", "3", "4", "a", "b", "c", "d" or "e".

[^CharSet] Any symbol not belonging to manifold CharSet.

For example, [^12a-e34] means any character excluding "1", "2", "3", "4", "a", "b", "c", "d" and "e".

Other symbols inside brackets are considered as characters but not special symbols. For instance, [$] is not a symbol of end of string but it is a character "$”.

Symbol ^ must stand right after "[", otherwise it means just a character "^”.