Professional Documents
Culture Documents
Regular Expressions Cheat Sheet: by Via
Regular Expressions Cheat Sheet: by Via
Regular Expressions Anchors Regular Expressions Quantifiers Regular Expressions Groups and Ranges
^ Start of string, or start of line in multi-line pattern * 0 or more . Any character except new line (\n)
\< Start of word Add a ? to a quantifier to make it ungreedy. [a-q] Letter from a to q
< >
[:upper:] Upper case letters Regular Expressions String Replacement
[:lower:] Lower case letters The escape character is usually the backslash - \.
$n nth non-passive group
[:alpha:] All letters $2 "xyz" in /^(abc(xyz))$/
Regular Expressions Special Characters
[:alnum:] Digits and letters $1 "xyz" in /^(?:abc)(xyz)$/
\n New line
[:digit:] Digits $` Before matched string
\r Carriage return
[:xdigit:] Hexadecimal digits $' After matched string
\t Tab
[:punct:] Punctuation $+ Last matched string
\v Vertical tab
[:blank:] Space and tab $& Entire matched string
\f Form feed
[:space:] Blank characters
Some regex implementations use \ instead of $.
\xxx Octal character xxx
[:cntrl:] Control characters
\xhh Hex character hh
[:graph:] Printed characters
?= Lookahead assertion
?! Negative lookahead
?# Comment
Dave Child (DaveChild) This cheat sheet was published on 19th October, 2011 FeedbackFair, increase your conversion rate today!
cheatography.com/davechild/ and was last updated on 14th November, 2012. Try it free!
www.addedbytes.com http://www.FeedbackFair.com