Regular Expressions

Jalatext uses regular expressions from java.util.regex.Pattern to implement inexact search and replace. A regular expression consists of a string where some characters are given special meaning with regard to pattern matching.

Within a regular expression, the following characters have special meaning:

Characters

. matches any single character
\d matches any decimal digit
\D matches any non-digit
\n matches the newline character
\s matches any whitespace character
\xNN matches hexadecimal character code NN
\S matches any non-whitespace character
\t matches a horizontal tab character
\w matches any word (alphanumeric) character
\W matches any non-word (alphanumeric) character
\\ matches the backslash ("\") character

Character classes

[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 will be interpreted literally

Boundary matchers

^ matches at the beginning of a line
$ matches at the end of a line
\B matches at a non-word break
\b matches at a word boundary

Branching (alternation) operator

a|b matches whatever the expression a would match, or whatever the expression b would match.

Repeating operators (Greedy quantifiers)

These symbols operate on the previous atomic expression.
? matches the preceding expression or the null string
* matches the null string or any number of repetitions of the preceding expression
+ matches one or more repetitions of the preceding expression
{m} matches exactly m repetitions of the one-character expression
{m,n} matches between m and n repetitions of the preceding expression, inclusive
{m,} matches m or more repetitions of the preceding expression

Examples

These are some examples of regular expression: