Java RegExp

§Meta characters
([{\^$|)?*+

•Escape meta character
\
\Q\E

§Classes
are enclosed within []
•Simple class
[abc]: a, b, or c
•Negation
[^abc]: any character except a,b,c
•Ranges
[a-c]: character a to c
•Unions
[0-4[6-8]]
•Intersections
[0-9&&[345]]: 3,4,5
•Substraction
[0-9&&[^345]]: except 3,4,5

§Predefined character classes
. any character
\d a digit [0-9]
\D a non digit [^0-9]
\s a whitespace character
\S a non-whitespace character
\w a word character [a-zA-Z_0-9]
\W a non-word character[^\w]

§Qualifiers
greedy reluctant possessive
x? x?? x?+
X*
x+
x{n}
x{n,}
x{n,m}

§Capturinq groups
()

§Back reference
(\d\d)\1

§Boundary Matchers
^ begin of a line
$ end of a line
\b a word boundary
\B a non-word boundary
\A beqin of the input
\G end of previous match
\Z end of the input but for the final terminator, if any
\z end of input

This entry was posted in java. Bookmark the permalink.