Returns the part of the string
subject that matches the regular expression
pattern, or an empty string if
pattern was not found.
The function follows the case sensitivity rules of the effective collation. Matching is performed case insensitively for case insensitive collations, and case sensitively for case sensitive collations and for binary data.
The collation case sensitivity can be overwritten using the (?i) and (?-i) PCRE flags.
MariaDB uses the PCRE regular expression library for enhanced regular expression performance, and
REGEXP_SUBSTR was introduced as part of this enhancement.
The default_regex_flags variable addresses the remaining compatibilities between PCRE and the old regex library.
SELECT REGEXP_SUBSTR('ab12cd','[0-9]+'); -> 12 SELECT REGEXP_SUBSTR( 'See https://mariadb.org/en/foundation/ for details', 'https?://[^/]*'); -> https://mariadb.org
SELECT REGEXP_SUBSTR('ABC','b'); -> B SELECT REGEXP_SUBSTR('ABC' COLLATE utf8_bin,'b'); -> SELECT REGEXP_SUBSTR(BINARY'ABC','b'); -> SELECT REGEXP_SUBSTR('ABC','(?i)b'); -> B SELECT REGEXP_SUBSTR('ABC' COLLATE utf8_bin,'(?+i)b'); -> B
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.