REGEXP_SUBSTR was introduced in MariaDB 10.0.5.
REGEXP_SUBSTR(subject,pattern)
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 10.0.5 switched to the PCRE regular expression library for enhanced regular expression performance, and REGEXP_SUBSTR
was introduced as part of this enhancement.
MariaDB 10.0.11 introduced the default_regex_flags variable to address 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
© 2019 MariaDB
Licensed under the Creative Commons Attribution 3.0 Unported License and the GNU Free Documentation License.
https://mariadb.com/kb/en/regexp_substr/