Appendix E. Regular Expressions

jEdit uses regular expressions from java.util.regex.Pattern to implement inexact search and replace. Click there to see a complete reference guide to all supported meta-characters.

A regular expression consists of a string where some characters are given special meaning with regard to pattern matching.

Inside XML files

Inside XML files (such as jEdit mode files), it is important that you escape XML special characters, such as &, <, >, etc. You can use the XML plugin's "characters to entities" to perform this mapping.

Inside Java / beanshell / properties files

Java strings are always parsed by java before they are processed by the regular expression engine, so you must make sure that backslashes are escaped by an extra backslash (\\)

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

Positional Operators

One-Character Operators

Character Class Operator

Subexpressions and Backreferences

Branching (Alternation) Operator

Repeating Operators

These symbols operate on the previous atomic expression.

Stingy (Minimal) Matching

If a repeating operator (above) is immediately followed by a ?, the repeating operator will stop at the smallest number of repetitions that can complete the rest of the match.

On regex search

There are some known issues with the java.util.regex library, as it stands in Java. In particular, it is possible to create regular expressions that hang the JVM, or cause stack overflow errors, which was not as easy to accomplish using the legacy gnu.regexp library. If you find that gnu.regexp, used in jEdit 4.2 and earlier, is more suitable for your search/replace needs, you can try the XSearch plugin, which still uses it and can provide a replacement to the built-in search dialog.