Your SlideShare is downloading. ×
0
Regular Expressions - Quick Reference GuideAnchors                              Literal Characters^                       ...
Upcoming SlideShare
Loading in...5
×

Regex cheatsheet

612

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
612
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
10
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Regex cheatsheet"

  1. 1. Regular Expressions - Quick Reference GuideAnchors Literal Characters^ Character group contents start of line$ end of line Letters and digits match exactly axB70 x individual charsb word boundary Some special characters match exactly @-=% x-y character rangeB not at word boundary [:class:] posix char classA start of subject Escape other specials with backslash . $ [G first match in subject [^:class:] negated classz end of subject Character GroupsZ end of subject Almost any character (usually not newline) . Examples or before newline at end [a-zA-Z0-9_] Lists and ranges of characters [ ]Non-printing characters Any character except those listed [^ ] [[:alnum:]_]a alarm (BEL, hex 07)cx "control-x"e escape (hex 1B) Counts (add ? for non-greedy) Commentsf formfeed (hex 0C) 0 or more ("perhaps some") * (?#comment)n newline (hex 0A) 0 or 1 ("perhaps a") ?r carriage return (hex OD)t 1 or more ("some") + Conditional subpatterns tab (hex 09)ddd octal code ddd Between "n" and "m" of {n,m} (?(condition)yes-pattern)xhh hex code hh Exactly "n", "n" or more {n}, {n,} (?(condition)yes|no-pattern)x{hhh..} hex code hhh..Generic character types Alternation Recursive patternsd decimal digit Either/or | (?n) NumberedD not a decimal digit (?0) (?R) Entire regexs whitespace characterS Lookahead and Lookbehind (?&name) Named not a whitespace charw "word" character Followed by (?= )W "non-word" character NOT followed by (?! ) ReplacementsPOSIX character classes Following (?<= ) $n reference capturealnum letters and digits NOT following (?<! )alpha letters Case foldingsascii character codes 0-127blank Grouping u upper case next char space or tab onlycntrl control characters For capture and counts ( ) U upper case followingdigit decimal digits Non-capturing (?: ) l lower case next chargraph printing chars -space L lower case followinglower lower case letters Named captures (?<name> )print printing chars +space Alternation E end case foldingpunct printing chars -alnum Back referencesspace white space Conditional insertionsupper Numbered n gn g{n} upper case letters (?n:insertion)word "word" characters Relative g{-n}xdigit hexadecimal digits Named k<name> (?n:insertion:otherwise) http://www.e-texteditor.com
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×