Created
January 9, 2014 16:23
-
-
Save dreampowder/8337031 to your computer and use it in GitHub Desktop.
Java Regex Cheat Sheet (taken from: http://stackoverflow.com/questions/3847294/replace-all-characters-not-in-range-java-string)
This file contains 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
[aeiou] - matches exactly one lowercase vowel | |
[^aeiou] - matches a character that ISN'T a lowercase vowel (negated character class) | |
^[aeiou] - matches a lowercase vowel anchored at the beginning of the line | |
[^^] - matches a character that isn't a caret/'^' | |
^[^^] - matches a character that isn't a caret at the beginning of line | |
^[^.]. - matches anything but a literal period, followed by "any" character, at the beginning of line | |
[a-z] - matches exactly one character within the range of 'a' to 'z' (i.e. all lowercase letters) | |
[az-] - matches either an 'a', a 'z', or a '-' (literal dash) | |
[.*]* - matches a contiguous sequence (possibly empty) of dots and asterisks | |
[aeiou]{3} - matches 3 consecutive lowercase vowels (all not necessarily the same vowel) | |
\[aeiou\] - matches the string "[aeiou]" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment