Documentation

SQL regular expression functions

The InfluxDB Cloud Serverless 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_count

Returns the number of matches that a regular expression has in a string.

regexp_count(str, regexp[, start, flags])
  • Copy
  • Fill window
Arguments
  • str: String expression to operate on. Can be a constant, column, or function, and any combination of operators.
  • regexp: Regular expression to operate on. Can be a constant, column, or function, and any combination of operators.
  • start: Optional start position (the first position is 1) to search for the regular 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_count query example

regexp_like

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

regexp_like(str, regexp[, flags])
  • Copy
  • Fill window
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_like query example

regexp_match

Returns a list of regular expression matches in a string.

regexp_match(str, regexp, flags)
  • Copy
  • Fill window
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_match query example

regexp_replace

Replaces substrings in a string that match a regular expression.

regexp_replace(str, regexp, replacement, flags)
  • Copy
  • Fill window
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.

Read more

InfluxDB 3 Core and Enterprise are now in Beta

InfluxDB 3 Core and Enterprise are now available for beta testing, available under MIT or Apache 2 license.

InfluxDB 3 Core is a high-speed, recent-data engine that collects and processes data in real-time, while persisting it to local disk or object storage. InfluxDB 3 Enterprise is a commercial product that builds on Core’s foundation, adding high availability, read replicas, enhanced security, and data compaction for faster queries. A free tier of InfluxDB 3 Enterprise will also be available for at-home, non-commercial use for hobbyists to get the full historical time series database set of capabilities.

For more information, check out:

InfluxDB Cloud Serverless