J uses the gnu.regexp package.
^
matches the beginning of a line
$
matches the end of a line
.
matches any single character
\d
matches any decimal digit
\D
matches any non-digit
\n
matches a newline character
\r
matches a return character
\s
matches any whitespace character
\S
matches any non-whitespace character
\t
matches a tab character
\w
matches any word (alphanumeric) character
\W
matches any non-word (alphanumeric) character
Otherwise,
\c
matches the character c.
[abc]
matches any character in the set a, b or c
[^abc]
matches any character not in the set a, b or c
[a-z]
matches any character in the range a to z (inclusive)
A leading or trailing dash is interpreted literally.
(abc)
matches whatever the expression abc would match, and saves it as a subexpression
\n
where 1 <= n <= 9, matches the same thing the nth subexpression matched
Parentheses can also be used for grouping.
Parentheses used for grouping or to record matched subexpressions should not be escaped.
Backreferences may also be used in replacement strings; see replace.
a|b
matches whatever the expression a would match, or whatever the expression b would match.
?
matches zero or one occurrence of the preceding expression or the null string
*
matches zero or more occurrences of the preceding expression
+
matches one or more occurrences of the preceding expression
{m}
matches exactly m occurrences of the preceding expression
{m,n}
matches between m and n occurrences of the preceding expression (inclusive)
{m,}
matches m or more occurrences of the preceding expression
The repeating operators operate on the preceding atomic expression.
If a repeating operator is immediately followed by a ?, the repeating operator will stop at the smallest number of repetitions that can complete the rest of the match.