Regex

edit

By default, Lucee uses the older Apache ORO Regex Engine (also known as “Perl” mode), which is compatible with ACF.

Since 5.3.8.79, Lucee also supports using the more modern engine built into Java.

The Java engine is faster, supports modern features like look-behinds and named groups, and is actively maintained. See Java Regex Engine for a full migration guide.

You can switch engines using the following options in your Application.cfc / <cfapplication>

this.regex = { engine: “java” };  // default is “perl”
// or
this.useJavaAsRegexEngine = true;

To switch between Regex engines on the fly (<cfapplication> only affects the current thread / request)

<!--- do perl regex stuff --->
<cfapplication action=”update” regex=”java”>
<!--- do modern java regex stuff --->
<cfapplication action=”update” regex=”perl”>
<!--- back to perl regex stuff --->

Functions

  • IsValid()

    Tests whether a value meets a validation or data type rule.

  • REEscape()

    Escapes regular expression control characters within a string.

  • REFind()

    Uses a regular expression (RE) to search a string for a pattern. The search is case sensitive.

  • REFindNoCase()

    Uses a regular expression (RE) to search a string for a pattern, starting from a specified position. The search is case-insensitive.

  • REMatch()

    Uses a regular expression (RE) to search a string for a pattern, starting from a specified position.

  • REMatchNoCase()

    Uses a regular expression (RE) to search a string for a pattern, starting from a specified position.

  • REReplace()

    Uses a regular expression (RE) to search a string for a string pattern and replace it with another. The search is case-sensitive.

  • REReplaceNoCase()

    Uses a regular expression to search a string for a string pattern and replace it with another. The search is case-insensitive.

Methods

  • string.reEscape()

    Escapes regular expression control characters within a string.

  • string.reFind()

    Uses a regular expression (RE) to search a string for a pattern. The search is case sensitive.

  • string.reFindNoCase()

    Uses a regular expression (RE) to search a string for a pattern, starting from a specified position. The search is case-insensitive.

  • string.REMatch()

    Uses a regular expression (RE) to search a string for a pattern, starting from a specified position.

  • string.REMatchNoCase()

    Uses a regular expression (RE) to search a string for a pattern, starting from a specified position.

  • string.rEReplace()

    Uses a regular expression (RE) to search a string for a string pattern and replace it with another. The search is case-sensitive.

  • string.rEReplaceNoCase()

    Uses a regular expression to search a string for a string pattern and replace it with another. The search is case-insensitive.

Guides

  • Java Regex Engine

    How to switch from the legacy Apache ORO regex engine to Java's built-in regex engine for better performance and modern features.