regex guide

From thelinuxwiki
Revision as of 23:30, 13 May 2017 by Nighthawk (Talk | contribs)

Jump to: navigation, search

regular-expressions.info

special chacters

\ ^ $ . | ? * + ( ) [ {

Most regular expression flavors treat the brace { as a literal character, unless it is part of a repetition operator like a{1,3}

Some flavors also support the \Q…\E escape sequence. All the characters between the \Q and the \E are interpreted as literal characters. E.g. \Q*\d+*\E matches the literal text *\d+*.

The backslash in combination with a literal character can create a regex token with a special meaning. E.g. \d is a shorthand that matches a single digit from 0 to 9.


Programming Languages

In your source code, you have to keep in mind which characters get special treatment inside strings by your programming language. That is because those characters are processed by the compiler, before the regex library sees the string.