JadeRegexLibrary Class

The JadeRegexLibrary class is the abstract superclass of the regular expression (Regex) pattern‑matching Application Programming Interface (API) in JADE. This API reduces hand‑crafted string parsing and code manipulation, to assist in the reading and testing of your code. JADE does not implement a Regex engine itself, but wraps an existing implementation (the Perl Compatible Regular Expressions (PCRE) dialect) with defined behavior and documentation. (For details, see https://www.pcre.org/current/doc/html/pcre2syntax.html.)

Use the dollar symbol $ character to indicate that the replacement is text from a specific capture group (for example, $1 $captureGroupName, where 1 is the number of the capture group). If you do not want capture group functionality, escape from it with another dollar symbol. If you do not do so, an exception can occur if the text string following the $ character is an invalid capture group. You can have named capture groups; for example, $1 to specify the first capture group and $0 for the whole match. If the first capture group is named, you can use either $1 or $captureGroupName, where captureGroupName is the name of the capture group that you defined.

The JADE regular expression pattern‑matching can be used for many use cases, including:

The subclasses of the JadeRegexLibrary superclass are summarized in the following table.

Class Description
JadeRegex Contains type methods for quick, simple use of the JadeRegexLibrary. Each method has common options that suit many use cases.
JadeRegexCapture A capture group of your regular expression, containing information about it; for example, the text it matched, the group name, length, and so on.
JadeRegexMatch A single match of your regular expression against the subject string. It optionally contains JadeRegexCapture objects if capturing groups is enabled.
JadeRegexPattern A compiled Regex object that provides enhanced functionality and performance over the JadeRegex class and its type methods.
JadeRegexResult An object representing one or more matches resulting from a Regex operation.

In addition, the JadeRegexException subclass of the NormalException class is the transient class that defines details for exceptions that occur as a result of JADE regular expression pattern matching.

The JADE Regex API provides two separate APIs based around the JadeRegex and JadeRegexPattern classes, respectively. These address two distinct programming use cases and styles. The JadeRegex class provides a simpler experience suitable for many common situations by using common defaults and simplified parameters, while the JadeRegexPattern class provides a more‑efficient API for consecutive uses, because the pattern is not compiled with every Regex operation.

Object

JadeRegex, JadeRegexCapture, JadeRegexMatch, JadeRegexPattern, JadeRegexResult

2020.0.01 and higher