Special Characters for Regular Expressions

From English wiki app24.online
Jump to navigation Jump to search


In the table below, you can find most frequently used special characters. You can find the full list of character in topic “Regular Expression Operations”.

Special Character Description Regular Expression Example Examples of Words That Can Be Found Using Regular Expression
. Any single character, except for a new line \n p.pp.r. pepper, p0pp0r
\d Any digit Boeing\d\d Boeing2707, Boeing787
\D Any character, except for a digit 926\D123 926)123, 1926-123
\s Space, line break, end of line, etc. sushi\spizza sushi pizza
\S Any character, except for a space, tab, end of line, etc. \S123 X123, i123, !123
\w Any letter (anything that can be a part of a word), as well as digits and low line (_) \w\w\w Year, f_3, qwe
\W Any character, except for a letter, digit, or low line (_) com\W com!, com?
[..] Single character that belongs to the range of digits or letters [0-9][A-F] 1B, 4F, 0D
[^..] Any character, except for those listed within the brackets <[^>]> <1>

In the table below, you can find the list of special characters that allow you to set the number of repetitions (quantifiers).

Special Character Description Regular Expression Example Examples of Words That Can Be Found Using Regular Expression
{n} n repetitions exactly \d{4}

Regular expression searches for any four digits that follow each other

1234, 8790, 7564
{m,n} From m to n repetitions inlcuded \d{2,4}

Regular expression searches for any two, three, or four digits that follow each other

12, 123, 1234, 54, 765, 9999
{m,} No less than m repetitions \d{3,}

Regular expression searches for at least any three digits that follow each other

123, 4567, 0987654
{,n} No more than n repetitions \d{,2}

Regular expression searches for no more than any two digits that follow each other

0, 3, 44, 56
* Zero or more repetitions. You can replace it by {0,} Boing\d*

Regular expression searches for phrases that start with word Boeing followed by no digits or several digits

Boeing, Boeing1, Boeing2345
+ One repetition or more. You can replace it by {1,} a)+

Regular expression searches for phrases that have at least one bracket ) after letter a

a), a)), a)))

By default, quantifiers are “greedy”, i.e. they capture as much characters as possible. Add a question mark (?) after a quantifier to make it “lazy”.