Davechild Regular-Expressions PDF
Davechild Regular-Expressions PDF
Regular Expressions Anchors ^ \A $ \Z \b \B \< \> Start of string, or start of line in multi-line pattern Start of string End of string, or end of line in multi-line pattern End of string Word boundary Not word boundary Start of word End of word Regular Expressions Quantifiers * + ? {3} {3,} {3,5} 0 or more 1 or more 0 or 1 Exactly 3 3 or more 3, 4 or 5
"Escaping" is a way of treating characters which have a special meaning in regular expressions literally, rather than as special characters. Regular Expression Common Metacharacters ^ $ ( [ { \ | > . * + ?
Regular Expressions POSIX [:upper:] [:lower:] [:alpha:] [:alnum:] [:digit:] [:xdigit:] [:punct:] [:blank:] [:space:] [:cntrl:] [:graph:] [:print:] [:word:] Upper case letters Lower case letters All letters Digits and letters Digits Hexadecimal digits Punctuation Space and tab Blank characters Control characters Printed characters Printed characters and spaces Digits, letters and underscore
) <
Regular Expressions String Replacement $n $2 $1 $` $' $+ $& nth non-passive group "xyz" in /^(abc(xyz))$/ "xyz" in /^(?:abc)(xyz)$/ Before matched string After matched string Last matched string Entire matched string
The escape character is usually the backslash - \. Regular Expressions Special Characters \n \r \t \v \f \xxx \xhh New line Carriage return Tab Vertical tab Form feed Octal character xxx Hex character hh
Regular Expressions Assertions ?= ?! ?<= ?!= or ?<! ?> ?() ?()| ?# Cheatographer Dave Child (DaveChild) cheatography.com/davechild/ www.addedbytes.com Lookahead assertion Negative lookahead Lookbehind assertion Negative lookbehind Once-only Subexpression Condition [if then] Condition [if then else] Comment Cheat Sheet This cheat sheet was published on 19th October, 2011 and was last updated on 14th November, 2012. Sponsor FeedbackFair , increase your conversion rate today! Try it free! http://www.FeedbackFair.com