Documentation

    regexp_extract

    Return the part of text that matches a regular expression, or empty text if there is no match. An optional constant group number picks a capturing group, and regex options can follow.

    Try an expression

    In Formula, enter the expression and set Output type to VARCHAR.

    Expression

    regexp_extract('ABC', '([a-z])(b)', 1, 'i')

    Result

    'A'

    To use your own data, replace the example values with column names. Keep format strings and other options as written.

    Arguments and types

    regexp_extract(string, regex, name_list, options)
    string
    Text
    regex
    Text
    group
    Number
    options
    Text
    name_list
    List
    Supported signatures (5)
    regexp_extract(string: VARCHAR, regex: VARCHAR) → VARCHAR
    regexp_extract(string: VARCHAR, regex: VARCHAR, group: INTEGER) → VARCHAR
    regexp_extract(string: VARCHAR, regex: VARCHAR, group: INTEGER, options: VARCHAR) → VARCHAR
    regexp_extract(string: VARCHAR, regex: VARCHAR, name_list: VARCHAR[]) → VARCHAR
    regexp_extract(string: VARCHAR, regex: VARCHAR, name_list: VARCHAR[], options: VARCHAR) → VARCHAR

    The result type can depend on the input types. See DuckDB for the full argument rules.

    Things to know

    If the first argument is missing, the result is NULL.

    Browse patternsDuckDB documentation

    Function metadata from DuckDB, used under the MIT license.