General Tokens
\n Newline\r Carriage return\t Tab\0 Null characterAnchors
\G Start of match. Will match at the position the previous successful match ended^ Start of string (multiline mode). Will match after each newline character$ End of string (multiline mode). Will match before each newline character\A Start of string\Z End of string. Will match before last newline character\z End of string. Will match at the end of a string\b A word boundary. Will match between \w and \W\B Non-word boundary. Will match between two characters matched by \wMeta Sequences
. Any single character\s Any whitespace\S Any non-whitespace\d Any digit\D Any non-digit\w Any word\W Any non-word\X Any unicode sequences\C Match one data unit\R Unicode newline\v Vertical whitespace\h Horizontal whitespace\H Non-horizontal whitespace\K Reset match: sets the given position as the new start\n Match nth subpattern (backreference)\pX Unicode property X\PX Non-unicode property X\p{...} Unicode properties\P{...} Non-unicode properties\Q...\E Any characters between will be treated as literals\k<name> Match subpattern 'name'\k'name' Match subpattern 'name'\k{name} Match subpattern 'name'\gn Match nth subpattern\g{n} Match nth subpattern\g{-n} Match nth group before current position\g'name' Recurse subpattern 'name'\g<n> Recurse nth subpattern\g'n' Recurse nth subpattern\g<+n> Recurse nth relative subpattern\g'+n' Recurse nth relative subpattern\xYY Hex character YY\x{YYYY} Hex character YYYY\ddd Octal character ddd\cY Control character Y\b Backspace character\ Makes any character literalQuantifiers
a? Zero or one aa* Zero or more of aa+ One or more of aa{3} Exactly 3 of aa{3,} 3 or more of aa{3,6} Between 3 and 6 of aa* Greedy quantifiera*? Lazy/Reluctant quantifiera*+ Possessive quantifierGroup Constructs
(...) Capture everything enclosed(a|b) a or b(?:...) Match everything enclosed but won't create a capture group(?>...) Atomic group(?|...) Duplicate subpattern group(?#...) Comment(?'name'...) Named capturing group(?<name>...) Named capturing group(?P<name>...) Named capturing group(?imsxXU) Inline modifiers(?(...)|) Conditional statement(?R) Recurse entire pattern(?1) Recurse first subpattern(?+1) Recurse first relative subpattern(?&name) Match subpattern 'name'(?P>name) Match subpattern 'name'(?=...) Positive lookahead(?!...) Negative lookahead(?<=...) Positive lookbehind(?<!...) Negative lookbehindCharacter classes
[abc] A character: a, b or c[^abc] A character except: a, b or c[a-z] A character in the range: a-z[a-z] A character not in the range: a-z[a-zA-Z] A character in the range: a-z or A-Z[[:alnum:]] Letter or digit[[:alpha:]] Letter[[:ascii:]] Ascii code in the range: 0-127[[:blank:]] Space or tab[[:cntrl:]] Control character[[:digit:]] Digit[[:graph:]] Visible character (not space)[[:lower:]] Lower character[[:print:]] Visible character[[:punct:]] Visible punctuation character[[:space:]] Whitespace[[:upper:]] Uppercase character[[:word:]] Word[[:xdigit:]] Hexadecimal digitFlags/Modifiers
g Globalm Multilinei Case insensitivex Ignore whitespaces Single lineu UnicodeX ExtendedU UngreedyA AnchorSubstitution
\0 Complete match contents\1 Contents in capture group 1\g<1> Contents in capture group 1$1 Contents in capture group 1${foo} Contents in capture group 'foo'\{foo} Contents in capture group 'foo'\g{foo} Contents in capture group 'foo'\xYY Hexadecimal replacement\x{YYZZ} Hexadecimal replacement\t Tab\r Carriage return\n Newline\f Form-feedPCRE tester
#perl -Mre=debugcolor -e '"preval(" =~ /(^|\s)eval\(/'#perl -Mre=debugcolor -e '"eval(" =~ /(^|\s)eval\(/'
References
http://pcre.org/pcre.txt
No comments:
Post a Comment