Supported Syntax
RegExPlus includes the regular expression syntax supported by Java, plus new syntax, which has been highlighted for ease of reference.
Information was copied from Oracle's Javadocs and appended with the added functionality.
Characters
x
The character x\\
The backslash character\0n
The character with octal value0n
(0 <= n <= 7)\0nn
The character with octal value0nn
(0 <= n <= 7)\0mnn
The character with octal value0mnn
(0 <= m <= 3, 0 <= n <= 7)\xhh
The character with hexadecimal value0xhh
\uhhhh
The character with hexadecimal value0xhhhh
\x{h..h}
The character with hexadecimal value0xh...h
\t
The tab character ('\u0009')\n
The newline (line feed) character ('\u000A')\r
The carriage-return character ('\u000D')\f
The form-feed character ('\u000C')\a
The alert (bell) character ('\u0007')\e
The escape character ('\u001B')\cx
The control character corresponding tox
Character classes
[abc]
a
,b
, orc
(simple class)[^abc]
Any character excepta
,b
, orc
(negation)[a-zA-Z]
a
throughz
orA
throughZ
, inclusive (range)[a-d[m-p]]
a
throughd
, orm
throughp
:[a-dm-p]
(union)[a-z&&[def]]
d
,e
, orf
(intersection)[a-z&&[^bc]]
a
throughz
, except forb
andc
:[ad-z]
(subtraction)[a-z&&[^m-p]]
a
throughz
, and notm
throughp
:[a-lq-z]
(subtraction)
Predefined character classes
.
Any character (may or may not match line terminators)\X
Single grapheme - equivalent to(?>\P{M}\p{M}*)
\d
A digit:[0-9]
\D
A non-digit:[^0-9]
\h
A horizontal whitespace character:[ \t\xA0\u1680\u180e\u2000-\u200a\u202f\u205f\u3000]
\H
A non-horizontal whitespace character:[^\h]
\s
A whitespace character:[ \t\n\x0B\f\r]
\S
A non-whitespace character:[^\s]
\v
A vertical whitespace character:[\n\x0B\f\r\x85\u2028\u2029]
\V
A non-vertical whitespace character:[^\v]
\w
A word character:[a-zA-Z_0-9]
\W
A non-word character:[^\w]
POSIX character classes (US-ASCII only)
For more details, see the page on POSIX character classes
\p{Lower}
A lower-case alphabetic character:[a-z]
\p{Upper}
An upper-case alphabetic character:[A-Z]
\p{ASCII}
All ASCII:[\x00-\x7F]
\p{Alpha}
An alphabetic character:[\p{Lower}\p{Upper}]
\p{Digit}
A decimal digit:[0-9]
\p{Alnum}
An alphanumeric character:[\p{Alpha}\p{Digit}]
\p{Punct}
Punctuation: One of!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
\p{Graph}
A visible character:[\p{Alnum}\p{Punct}]
\p{Print}
A printable character:[\p{Graph}\x20]
\p{Blank}
A space or a tab:[ \t]
\p{Cntrl}
A control character:[\x00-\x1F\x7F]
\p{XDigit}
A hexadecimal digit:[0-9a-fA-F]
\p{Space}
A whitespace character:[ \t\n\x0B\f\r]
POSIX character classes (US-ASCII only)
Equivalent to the above POSIX classes - only allowed in a character class
For more details, see the page on POSIX character classes
[:lower:]
A lower-case alphabetic character:[a-z]
[:upper:]
An upper-case alphabetic character:[A-Z]
[:ascii:]
All ASCII:[\x00-\x7F]
[:alpha:]
An alphabetic character:[[:lower:][:upper:]]
[:digit:]
A decimal digit:[0-9]
[:alnum:]
An alphanumeric character:[[:alpha:][:digit:]]
[:punct:]
Punctuation: One of!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
[:graph:]
A visible character:[[:alnum:][:punct:]]
[:print:]
A printable character:[[:graph:]\x20]
[:blank:]
A space or a tab:[ \t]
[:cntrl:]
A control character:[\x00-\x1F\x7F]
[:xdigit:]
A hexadecimal digit:[0-9a-fA-F]
[:space:]
A whitespace character:[ \t\n\x0B\f\r]
[:word:]
A word character:[\w]
java.lang.Character classes (simple java character type)
\p{javaLowerCase}
Equivalent to java.lang.Character.isLowerCase()\p{javaUpperCase}
Equivalent to java.lang.Character.isUpperCase()\p{javaWhitespace}
Equivalent to java.lang.Character.isWhitespace()\p{javaMirrored}
Equivalent to java.lang.Character.isMirrored()
Classes for Unicode blocks and categories
\p{InGreek}
A character in the Greek block (simple block)\p{Lu}
An uppercase letter (simple category)\p{Sc}
A currency symbol\P{InGreek}
Any character except one in the Greek block (negation)[\p{L}&&[^\p{Lu}]]
Any letter except an uppercase letter (subtraction)
Boundary matchers
^
The beginning of a line$
The end of a line\b
A word boundary\B
A non-word boundary\A
The beginning of the input\G
The end of the previous match\Z
The end of the input but for the final terminator, if any\z
The end of the input
Greedy quantifiers
X?
X, once or not at allX*
X, zero or more timesX+
X, one or more timesX{n}
X, exactly n timesX{n,}
X, at least n timesX{n,m}
X, at least n but not more than m times
Reluctant quantifiers
X??
X, once or not at allX*?
X, zero or more timesX+?
X, one or more timesX{n}?
X, exactly n timesX{n,}?
X, at least n timesX{n,m}?
X, at least n but not more than m times
Possessive quantifiers
X?+
X, once or not at allX*+
X, zero or more timesX++
X, one or more timesX{n}+
X, exactly n timesX{n,}+
X, at least n timesX{n,m}+
X, at least n but not more than m times
Logical operators
XY
X followed by YX|Y
Either X or Y
Capturing
(X)
X, as a capturing group(?<name>X)
X, as a named-capturing group(?'name'X)
X, as a named-capturing group(?P<name>X)
X, as a named-capturing group
Back references
For more details, see the page on back references
\n
Whatever the nth capturing group matched\gn
Whatever the nth capturing group matched\g{n}
Whatever the nth capturing group matched\g-n
Relative back reference\g{-n}
Relative back reference\k<name>
Whatever the named-capturing group "name" matched\k'name'
Whatever the named-capturing group "name" matched\g{name}
Whatever the named-capturing group "name" matched\k{name}
Whatever the named-capturing group "name" matched(?P=name)
Whatever the named-capturing group "name" matched
Quotation
\
Matches nothing, but quotes the following character\Q
Matches nothing, but quotes all characters until \E\E
Matches nothing, but ends quoting started by \Q
Special constructs (non-capturing)
(?:X)
X, as a non-capturing group(?idmsuxJn-idmsuxJn)
Matches nothing, but turns match flags i d m s u x J n on - off(?idmsuxJn-idmsuxJn:X)
X, as a non-capturing group with the given flags i d m s u x J n on - off(?>X)
X, as an independent (atomic), non-capturing group(?|X)
X, as a "branch reset" pattern
Assertions (non-capturing)
(?=X)
X, via zero-width positive lookahead(?!X)
X, via zero-width negative lookahead(?<=X)
X, via zero-width positive lookbehind(?<!X)
X, via zero-width negative lookbehind
Comment (non-capturing)
(?x:#comment\n)
comment (cannot contain a line terminator)(?xd:#comment\n)
comment (cannot contain '\n')(?#comment)
comment (cannot contain a close parenthesis)
Conditional patterns (non-capturing)
For more details, see the page on conditionals
(?(condition)yes-pattern)
(?(condition)yes-pattern|no-pattern)
Numeric ranges (non-capturing)
For more details, see the page on numeric ranges
(?Z[start..end])
matches a numeric range (allowing for leading zeros)(?Z16[start..end])
matches a numeric range in base 16 (allowing for leading zeros)(?NZ[start..end])
matches a numeric range (not allowing for leading zeros)(?NZ16[start..end])
matches a numeric range in base 16 (not allowing for leading zeros)