From e4a2ce2e8d902a91e2f9b7afd381967a53d4231d Mon Sep 17 00:00:00 2001 From: Masha Basmanova Date: Tue, 6 Feb 2024 16:13:57 -0800 Subject: [PATCH] Document regexp_extract_all(string, pattern) Presto function (#8689) Summary: The documentation for 2-arg regexp_extract_all(string, pattern) function was missing. Pull Request resolved: https://github.com/facebookincubator/velox/pull/8689 Reviewed By: kevinwilfong Differential Revision: D53494645 Pulled By: mbasmanova fbshipit-source-id: 11f83056c5b0ff3b20787db143631b27ba2b5c05 --- velox/docs/functions/presto/regexp.rst | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/velox/docs/functions/presto/regexp.rst b/velox/docs/functions/presto/regexp.rst index c032413fb3e5..c8a8f4b81ac6 100644 --- a/velox/docs/functions/presto/regexp.rst +++ b/velox/docs/functions/presto/regexp.rst @@ -34,14 +34,22 @@ See https://github.com/google/re2/wiki/Syntax for more information. SELECT regexp_extract('1a 2b 14m', '\d+'); -- 1 .. function:: regexp_extract(string, pattern, group) -> varchar - :noindex: + :noindex: Finds the first occurrence of the regular expression ``pattern`` in ``string`` and returns the capturing group number ``group``:: SELECT regexp_extract('1a 2b 14m', '(\d+)([a-z]+)', 2); -- 'a' -.. function:: regexp_extract_all(string, pattern, group) -> array(varchar) +.. function:: regexp_extract_all(string, pattern) -> array(varchar): + + Returns the substring(s) matched by the regular expression ``pattern`` + in ``string``:: + + SELECT regexp_extract_all('1a 2b 14m', '\d+'); -- [1, 2, 14] + +.. function:: regexp_extract_all(string, pattern, group) -> array(varchar): + :noindex: Finds all occurrences of the regular expression ``pattern`` in ``string`` and returns the capturing group number ``group``:: @@ -69,7 +77,7 @@ See https://github.com/google/re2/wiki/Syntax for more information. SELECT regexp_replace('1a 2b 14m', '\d+[ab] '); -- '14m' .. function:: regexp_replace(string, pattern, replacement) -> varchar - :noindex: + :noindex: Replaces every instance of the substring matched by the regular expression ``pattern`` in ``string`` with ``replacement``. Capturing groups can be referenced in