Created
December 10, 2012 21:49
-
-
Save koshov/4253684 to your computer and use it in GitHub Desktop.
RegExp cheat-sheet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ================= | |
| RegExp cheat-sheet | |
| ================= | |
| ^ beginning of line | |
| $ end of line | |
| . any character | |
| * zero or more | |
| ? zero or one | |
| + one or more | |
| {n} n times | |
| {n,} n or more times | |
| {n,m} n or no more than m times | |
| [all_of_above]? consuming as little input as possible | |
| [all_of_above]+ no input is returned for backtracking - all consumed | |
| \x where x = [1,9] matches the same input as subexpression x | |
| eg.: | |
| ^(a*).*\1$ | |
| matches aaabbaaa | |
| does not match aabbaaa | |
| | or, eg.: a(b|c) | |
| [abc] only the characters a,b and c | |
| [a-d] the characters from a to d | |
| [^a-e] all characters but the ones from a to e | |
| sequence equals | |
| \d [[:digit:]] | |
| \l [[:lower:]] | |
| \s [[:space:]] | |
| \u [[:upper:]] | |
| \w [[:word:]] | |
| \h Horizontal whitespace | |
| \v Vertical whitespace | |
| \D [^[:digit:]] | |
| \L [^[:lower:]] | |
| \S [^[:space:]] | |
| \U [^[:upper:]] | |
| \W [^[:word:]] | |
| \H Not Horizontal whitespace | |
| \V Not Vertical whitespace |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment