regular expression cheat sheet - qa distiller · unleash the power of regular expressions in qa...

1
Unleash the power of regular expressions in QA Distiller | www.qa-distiller.com REGULAR EXPRESSION CHEAT SHEET Special characters square bracket [ backslash \ caret ^ dollar sign $ period or dot . vertical bar or pipe symbol | question mark ? asterisk or star * plus sign + opening round bracket ( closing round bracket ) opening curly bracket { Shorthand character classes digit \d word character \w whitespace \s not a digit \D not a word character \W not a whitespace \S Lookaround positive lookahead (?=) positive lookbehind (?<=)negative lookahead (?!) negative lookbehind (?<!)Non-printable characters tab \t carriage return \r line feed \n beginning of line ^ end of line $ word boundary \b unicode character \x{0000} Alternation either/or |Grouping For capture and counts () Non-capturing (?:) Named captures (?<name>) Back references Numbered \Complete match \0 Named (?P=) Quantifiers once or not at all ? zero or more times * one or more times + exactly n times {n} at least n times {n,} at least n but not more than m times {n,m} Character classes almost any character (usually not newline) . lists and ranges of characters [] any character except those listed [^]

Upload: truongdang

Post on 29-Apr-2018

222 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: REGULAR EXPRESSION CHEAT SHEET - QA Distiller · Unleash the power of regular expressions in QA Distiller |  REGULAR EXPRESSION CHEAT SHEET Special characters square bracket [

Unleash the power of regular expressions in QA Distiller | www.qa-distiller.com

REGULAR EXPRESSION CHEAT SHEET Special characters square bracket [ backslash \ caret ^ dollar sign $ period or dot . vertical bar or pipe symbol |

question mark ? asterisk or star * plus sign + opening round bracket ( closing round bracket ) opening curly bracket {

Shorthand character classes digit \d word character \w whitespace \s

not a digit \D not a word character \W not a whitespace \S

Lookaround positive lookahead ⃞(?=⃞)

positive lookbehind (?<=⃞)⃞

negative lookahead ⃞(?!⃞)

negative lookbehind (?<!⃞)⃞

Non-printable characters tab \t carriage return \r line feed \n beginning of line ^ end of line $ word boundary \b

unicode character \x{0000}

Alternation either/or ⃞|⃞

Grouping For capture and counts (⃞)

Non-capturing (?:⃞)

Named captures (?<name>⃞)

Back references Numbered \⃞ Complete match \0 Named (?P=⃞)

Quantifiers once or not at all ⃞?

zero or more times ⃞*

one or more times ⃞+

exactly n times ⃞{n}

at least n times ⃞{n,}

at least n but not more than m times ⃞{n,m}

Character classes almost any character (usually not newline) . lists and ranges of characters [⃞]

any character except those listed [^⃞]