Regex literal

Learn how to represent regular expressions for pattern matching.

Regular expression, or Regex for short, provides a powerful and flexible way to match patterns in strings.

Croct's mascot neutral
What regex variant does CQL support?

CQL supports the PCRE variant, which is widely used and known for its rich feature set and strong performance.

A regular expression literal is expressed using the ~/ delimiter, followed by the pattern, a slash /, and optionally one or more modifiers.

Here is a basic example with all the parts:

In this example, the regular expression [a-z] matches any lowercase letter from a to z. The i modifier indicates that the match should be case-insensitive, allowing it to also match uppercase letters from A to Z.