[go: up one dir, main page]

0% found this document useful (0 votes)
93 views2 pages

Regular Expression Cheatsheet

Reference on four major flavors of regular expressions.

Uploaded by

Eric Weir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
93 views2 pages

Regular Expression Cheatsheet

Reference on four major flavors of regular expressions.

Uploaded by

Eric Weir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

String GNU grep BRE (grep) ERE (egrep) Perl Python

. any character any character except \0 any character except \n


[...] bracket expression character class
\(re\) subexpression
re\{...\} re multiple times
(re) subexpression grouping
re{...} re multiple times re multiple times
re{...}? nongreedy {}
\digit back-reference
^ start of line
$ end of line
re? re 0 or 1 times
re* re 0 or more times
re+ re one or more times
l|r l or r
*? non-greedy *
+? non-greedy +
?? non-greedy ?
\A start of string
\b either end of word either end of word
\B not either end of word not either end of word
\C any octet
\d digit
\D non-digit
\G at pos()
\p{property} Unicode property
\P{property} not Unicode property
\s whitespace
\S non-whitespace
\w alphanumeric alphanumeric and _
\W not alphanumeric not alphanumeric or _
\X combining sequence
\Z end of string/last line end of string
\z end of string
\< start of word
\> end of word
re\? re 0 or 1
re\+ re 1 or more
l\|r l or r
(?#text) comment, ignored
(?modifiers) embedded modifiers
shy grouping +
(?modifiers:re)
modifiers
(?:re) shy grouping
(?=re) lookahead
(?!re) negative lookahead
(?<=p) lookbehind
(?<!o) negative lookbehind
(??{code}) embedded perl
independent
(?>re)
expression
(?(cond)re|re) condition expression
(?P<name>re) symbolic grouping
(?P=name) symbolic backref
[:alnum:] alphanumeric characters
[:alpha:] alphabetic characters
[:blank:] blank characters (space, tab)
[:cntrl:] control characters
[:digit:] digits
[:graph:] graphical characters (alphanumeric and punctuation)
[:lower:] lowercase characters
[:print:] printable characters (alphanumeric, punctuation, and space)
[:space:] space characters (tab, newline, vertical tab, form feed, carriage return, space)
[:upper:] uppercase letters

You might also like