Documentation

SQL regular expression functions

The InfluxDB SQL implementation uses the PCRE-like regular expression syntax (excluding some features such as look-around and back-references) and supports the following regular expression functions:

regexp_like

True if a regular expression has at least one match in a string; false otherwise.

regexp_like(str, regexp[, flags])
Arguments
  • str: String expression to operate on. Can be a constant, column, or function, and any combination of string operators.
  • regexp: Regular expression to test against the string expression. Can be a constant, column, or function.
  • flags: Optional regular expression flags that control the behavior of the regular expression. The following flags are supported:
    • i: (insensitive) Ignore case when matching.
    • m: (multi-line) ^ and $ match the beginning and end of a line, respectively.
    • s: (single-line) . matches newline (\n).
    • R: (CRLF) When multi-line mode is enabled, \r\n is used to delimit lines.
    • U: (ungreedy) Swap the meaning of x* and x*?.

View regexp_replace query example

regexp_match

Returns a list of regular expression matches in a string.

regexp_match(str, regexp, flags)
Arguments
  • str: String expression to operate on. Can be a constant, column, or function, and any combination of string operators.
  • regexp: Regular expression to match against. Can be a constant, column, or function.
  • flags: Regular expression flags that control the behavior of the regular expression. The following flags are supported.
    • i: (insensitive) Ignore case when matching.

View regexp_replace query example

regexp_replace

Replaces substrings in a string that match a regular expression.

regexp_replace(str, regexp, replacement, flags)
Arguments
  • str: String expression to operate on. Can be a constant, column, or function, and any combination of string operators.
  • regexp: Regular expression to match against. Can be a constant, column, or function.
  • replacement: Replacement string expression. Can be a constant, column, or function, and any combination of string operators.
  • flags: Regular expression flags that control the behavior of the regular expression. The following flags are supported.
    • g: (global) Search globally and don’t return after the first match.
    • i: (insensitive) Ignore case when matching.

View regexp_replace query example


Was this page helpful?

Thank you for your feedback!


The future of Flux

Flux is going into maintenance mode. You can continue using it as you currently are without any changes to your code.

Flux is going into maintenance mode and will not be supported in InfluxDB 3.0. This was a decision based on the broad demand for SQL and the continued growth and adoption of InfluxQL. We are continuing to support Flux for users in 1.x and 2.x so you can continue using it with no changes to your code. If you are interested in transitioning to InfluxDB 3.0 and want to future-proof your code, we suggest using InfluxQL.

For information about the future of Flux, see the following:

InfluxDB Cloud Serverless