Function Name | Syntax | Description |
regexp_extract_all(x, regular expression) | Extracts substrings matching a regular expression from the target string and returns a collection of all matching substrings. | |
| regexp_extract_all(x, regular expression, n) | Extracts substrings matching a regular expression from the target string and returns a collection of substrings matching the target capturing group. |
regexp_extract(x, regular expression) | Extracts and returns the first substring matching a regular expression from the target string. | |
| regexp_extract(x, regular expression, n) | Extracts substrings matching a regular expression from the target string and returns the first substring matching the target capturing group. |
regexp_like (x, regular expression) | Determines whether the target string matches a regular expression. | |
regexp_replace (x, regular expression) | Delete the substrings that match a specified regular expression from a specified string and return the substrings that are not deleted. | |
| regexp_replace (x, regular expression, replace string) | Replace the substrings that match a specified regular expression in a specified string and return the new string after the replacement. |
regexp_split (x, regular expression) | Splits the target string with a regular expression, and returns a collection of substrings after splitting. | |
regexp_extract_all(x, regular expression)
regexp_extract_all(x, regular expression, n)
Parameter | Description |
x | The parameter value is of the varchar type. |
regular expression | The regular expression that contains capture groups. For example, (\\d)(\\d)(\\d) indicates three capture groups. |
n | The nth capture group. |
* | SELECT regexp_extract_all(http_protocol, '\\d+')
[1,1]
regexp_extract(x, regular expression)
regexp_extract(x, regular expression, n)
Parameter | Description |
x | The parameter value is of the varchar type. |
regular expression | The regular expression that contains capture groups. For example, (\\d)(\\d)(\\d) indicates three capture groups. |
n | The nth capture group. n is an integer that starts from 1. |
http_protocol field* | SELECT regexp_extract(http_protocol, '\\d+')
1
regexp_like function is used to check whether a specified string matches a specified regular expression.regexp_like (x, regular expression)
Parameter | Description |
x | The parameter value is of the varchar type. |
regular expression | Regular expression. |
server_protocol field contains digits.* | select regexp_like(server_protocol, '\\d+')
TRUE
regexp_replace function is used to delete or replace the substrings that match a specified regular expression in a specified string.regexp_replace (x, regular expression)
regexp_replace (x, regular expression, replace string)
Parameter | Description |
x | The parameter value is of the varchar type. |
regular expression | Regular expression. |
replace string | Substring that is used to replace the matched substring. |
server_protocol field and calculate the number of requests for each communication protocol.* | select regexp_replace(server_protocol, '.\\d+') AS server_protocol, count(*) AS count GROUP BY server_protocol
server_protocol | count |
HTTP | 357 |
* character to replace the digits in the original string hello123world, and use - to connect the parts of the string.* | SELECT regexp_replace('hello123world', '(hello)(\\d+)(world)', '$1-***-$3') as demo limit 1
demo |
hello-***-world |
regexp_split function is used to split a specified string into multiple substrings and return a collection of the substrings.regexp_split (x, regular expression)
Parameter | Description |
x | The parameter value is of the varchar type. |
regular expression | Regular expression. |
server_protocol field with forward slashes (/).* | select regexp_split(server_protocol, '/')
["HTTP","1.1"]
Was this page helpful?
You can also Contact sales or Submit a Ticket for help.
Help us improve! Rate your documentation experience in 5 mins.
Feedback