VeloDB Cloud
SQL Manual
Functions
string-functions
regexp
regexp_extract

regexp_extract

Description

Syntax:

VARCHAR regexp_extract (VARCHAR str, VARCHAR pattern, int pos)

This function performs regular matching on the string str, and extracts the No.pos part of the string that matches the condition specified by patter. If there is no matching parts, it will return an empty string.

Example

mysql> SELECT regexp_extract('AbCdE', '([[:lower:]]+)C([[:lower:]]+)', 1);
+-------------------------------------------------------------+
| regexp_extract('AbCdE', '([[:lower:]]+)C([[:lower:]]+)', 1) |
+-------------------------------------------------------------+
| b                                                           |
+-------------------------------------------------------------+

mysql> SELECT regexp_extract('AbCdE', '([[:lower:]]+)C([[:lower:]]+)', 2);
+-------------------------------------------------------------+
| regexp_extract('AbCdE', '([[:lower:]]+)C([[:lower:]]+)', 2) |
+-------------------------------------------------------------+
| d                                                           |
+-------------------------------------------------------------+

Keywords

REGEXP_EXTRACT,REGEXP,EXTRACT