This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris-website.git
The following commit(s) were added to refs/heads/master by this push:
new c73a37962af [Feature](func) Support REGEXP_EXTRACT_ALL_ARRAY (#3460)
c73a37962af is described below
commit c73a37962af880f6eafc626c8eb75bc1f9cb34d4
Author: linrrarity <[email protected]>
AuthorDate: Sat Oct 17 05:40:38 2026 +0800
[Feature](func) Support REGEXP_EXTRACT_ALL_ARRAY (#3460)
## Summary
Document the actual ARRAY<STRING> result of REGEXP_EXTRACT_ALL_ARRAY and
correct the existing REGEXP_EXTRACT_ALL result to STRING. Include
representative, empty-match, no-capture, NULL, and array-composition
examples.
## Versions
- [x] dev
- [x] 4.x
- [ ] 3.x
- [ ] 2.1 or older
REGEXP_EXTRACT_ALL_ARRAY is dev only: no implementation exists on
branch-4.0, branch-4.1, or branch-4.2. Corrections to the existing
STRING-returning REGEXP_EXTRACT_ALL page apply to both dev and 4.x.
Unrelated hash and historical-version edits are excluded.
## Languages
- [x] Chinese
- [x] English
## Validation
Reviewed against Doris master `88f22fd875e0be4dea2c58c53744f4074378a870`
and the corresponding current 4.0, 4.1, and 4.2 source branches. Rebased
onto website master `f582020241f825849ffa3b57fc3220cb674d28a7`.
- SQL function structure and internal-link checks passed for the final
changed pages.
- `git diff --check` passed.
- English and Chinese changes are synchronized. Remaining version-sync
notices are explained above.
- Doris and the website were not built; examples were checked against
source and existing regression expectations where available.
---------
Co-authored-by: morningman <[email protected]>
---
.../string-functions/regexp-extract-all-array.md | 82 ++++++++++++++++++++++
.../string-functions/regexp-extract-all.md | 42 ++++++++---
.../string-functions/regexp-extract-all-array.md | 82 ++++++++++++++++++++++
.../string-functions/regexp-extract-all.md | 46 ++++++++----
.../string-functions/regexp-extract-all.md | 47 +++++++++----
sidebars.ts | 1 +
.../string-functions/regexp-extract-all.md | 43 +++++++++---
7 files changed, 297 insertions(+), 46 deletions(-)
diff --git
a/docs/sql-manual/sql-functions/scalar-functions/string-functions/regexp-extract-all-array.md
b/docs/sql-manual/sql-functions/scalar-functions/string-functions/regexp-extract-all-array.md
new file mode 100644
index 00000000000..2c65d33af90
--- /dev/null
+++
b/docs/sql-manual/sql-functions/scalar-functions/string-functions/regexp-extract-all-array.md
@@ -0,0 +1,82 @@
+---
+{
+ "title": "REGEXP_EXTRACT_ALL_ARRAY",
+ "language": "en",
+ "description": "Extracts all matches of the first capturing group as a
string array."
+}
+---
+
+<version since="dev">
+
+</version>
+
+## Description
+
+Extracts every non-overlapping match of the first capturing group in
`<pattern>` from `<str>`, returning a string array in match order. Returns
`NULL` if either argument is `NULL`.
+
+## Syntax
+
+```sql
+REGEXP_EXTRACT_ALL_ARRAY(<str>, <pattern>)
+```
+
+## Parameters
+
+| Parameter | Description |
+| --- | --- |
+| `<str>` | Input string, of type `STRING`. |
+| `<pattern>` | Regular expression, of type `STRING`. The first capturing
group is extracted; a third group-index argument is not supported. |
+
+## Return Value
+
+Returns `ARRAY<STRING>`. Returns an empty array `[]` if there is no match or
no capturing group. Returns `NULL` if either argument is `NULL`. An invalid
regular expression raises an error.
+
+The default engine uses RE2 syntax and case-sensitive matching. The session
variable `enable_extended_regex` enables advanced regular expression features;
see [REGEXP_EXTRACT_ALL](./regexp-extract-all.md). This function returns an
array, while `REGEXP_EXTRACT_ALL` returns a formatted string.
+
+## Example
+
+```sql
+SELECT regexp_extract_all_array('id=12,id=34', 'id=([0-9]+)') AS result;
+```
+
+```text
+["12", "34"]
+```
+
+Use `(?i)` for case-insensitive matching:
+
+```sql
+SELECT regexp_extract_all_array('Hello hello HELLO', '(?i)(hello)') AS result;
+```
+
+```text
+["Hello", "hello", "HELLO"]
+```
+
+```sql
+SELECT regexp_extract_all_array('abc', '([0-9]+)') AS no_match,
+ regexp_extract_all_array('abc', 'abc') AS no_capture_group;
+```
+
+```text
+[] []
+```
+
+```sql
+SELECT regexp_extract_all_array(NULL, '(a)') AS null_input,
+ regexp_extract_all_array('a', NULL) AS null_pattern;
+```
+
+```text
+NULL NULL
+```
+
+The result can be passed directly to array functions:
+
+```sql
+SELECT array_size(regexp_extract_all_array('a1b2', '([0-9])')) AS matches;
+```
+
+```text
+2
+```
diff --git
a/docs/sql-manual/sql-functions/scalar-functions/string-functions/regexp-extract-all.md
b/docs/sql-manual/sql-functions/scalar-functions/string-functions/regexp-extract-all.md
index 5786ec2a5d1..528a209a96c 100644
---
a/docs/sql-manual/sql-functions/scalar-functions/string-functions/regexp-extract-all.md
+++
b/docs/sql-manual/sql-functions/scalar-functions/string-functions/regexp-extract-all.md
@@ -8,7 +8,7 @@
## Description
-The `REGEXP_EXTRACT_ALL` function is used to perform a regular expression
match on a given string `str` and extract all the parts that match the first
sub - pattern of the specified `pattern`. For the function to return an array
of strings representing the matched parts of the pattern, the pattern must
exactly match a portion of the input string `str`. If there is no match, or if
the pattern does not contain any sub - patterns, an empty string is returned.
+The `REGEXP_EXTRACT_ALL` function is used to perform a regular expression
match on a given string `str` and extract all the parts that match the first
sub - pattern of the specified `pattern`. The function returns a string
representing the matched part of the pattern, and the pattern must exactly
match a portion of the input string `str`. If there is no match, or if the
pattern does not contain any sub - patterns, an empty string is returned.
It should be noted that when handling character set matching, Utf-8 standard
character classes should be used. This ensures that functions can correctly
identify and process various characters from different languages.
@@ -29,13 +29,17 @@ REGEXP_EXTRACT_ALL(<str>, <pattern>)
## Parameters
| Parameter | Description |
-| -- | -- |
+| --- | --- |
| `<str>` | This parameter is of type String. It represents the input string
on which the regular expression matching will be performed. This can be a
literal string value or a reference to a column in a table that contains string
data.|
| `<pattern>` | This parameter is also of type String. It specifies the
regular expression pattern that will be used to match against the input string
<str>. The pattern can include various regular expression constructs such as
character classes, quantifiers, and sub - patterns.|
## Return value
-The function returns an array of strings that represent the parts of the input
string that match the first sub - pattern of the specified regular expression.
The return type is an array of String values. If no matches are found, or if
the pattern has no sub - patterns, an empty array is returned.
+Returns `NULL` if either argument is `NULL`.
+
+The function returns a string that represents the part of the input string
that matches the first sub - pattern of the specified regular expression. The
return type is String. If no matches are found, or if the pattern has no sub -
patterns, an empty string is returned.
+
+For the array-returning variant, see
[REGEXP_EXTRACT_ALL_ARRAY](./regexp-extract-all-array.md).
**Default Behavior**:
@@ -69,7 +73,10 @@ Pattern modifiers only take effect when using the default
regex engine. If `enab
Basic matching of lowercase letters around 'C'.In this example, the pattern
([[:lower:]]+)C([[:lower:]]+) matches the part of the string where one or more
lowercase letters are followed by 'C' and then one or more lowercase letters.
The first sub - pattern ([[:lower:]]+) before 'C' matches 'b', so the result is
['b'].
```sql
-mysql> SELECT regexp_extract_all('AbCdE', '([[:lower:]]+)C([[:lower:]]+)');
+SELECT regexp_extract_all('AbCdE', '([[:lower:]]+)C([[:lower:]]+)');
+```
+
+```text
+--------------------------------------------------------------+
| regexp_extract_all('AbCdE', '([[:lower:]]+)C([[:lower:]]+)') |
+--------------------------------------------------------------+
@@ -80,7 +87,10 @@ mysql> SELECT regexp_extract_all('AbCdE',
'([[:lower:]]+)C([[:lower:]]+)');
Multiple matches in a string. Here, the pattern matches two parts in the
string. The first match has the first sub - pattern matching 'b', and the
second match has the first sub - pattern matching 'f'. So the result is ['b',
'f'].
```sql
-mysql> SELECT regexp_extract_all('AbCdEfCg', '([[:lower:]]+)C([[:lower:]]+)');
+SELECT regexp_extract_all('AbCdEfCg', '([[:lower:]]+)C([[:lower:]]+)');
+```
+
+```text
+-----------------------------------------------------------------+
| regexp_extract_all('AbCdEfCg', '([[:lower:]]+)C([[:lower:]]+)') |
+-----------------------------------------------------------------+
@@ -88,10 +98,13 @@ mysql> SELECT regexp_extract_all('AbCdEfCg',
'([[:lower:]]+)C([[:lower:]]+)');
+-----------------------------------------------------------------+
```
-Extracting keys from key - value pairs.The pattern matches key - value pairs
in the string. The first sub - pattern captures the keys, so the result is an
array of the keys ['abc', 'def', 'ghi'].
+Extracting keys from key - value pairs.The pattern matches key - value pairs
in the string. The first sub - pattern captures the keys, so the result is
['abc', 'def', 'ghi'].
```sql
-mysql> SELECT regexp_extract_all('abc=111, def=222,
ghi=333','("[^"]+"|\\w+)=("[^"]+"|\\w+)');
+SELECT regexp_extract_all('abc=111, def=222,
ghi=333','("[^"]+"|\\w+)=("[^"]+"|\\w+)');
+```
+
+```text
+--------------------------------------------------------------------------------+
| regexp_extract_all('abc=111, def=222, ghi=333',
'("[^"]+"|\w+)=("[^"]+"|\w+)') |
+--------------------------------------------------------------------------------+
@@ -101,7 +114,10 @@ mysql> SELECT regexp_extract_all('abc=111, def=222,
ghi=333','("[^"]+"|\\w+)=("[
Matching Chinese characters.The pattern (\p{Han}+)(.+) first matches one or
more Chinese characters with the first sub - pattern (\p{Han}+), so the result
is ['这是一段中文'].
```sql
-mysql> select regexp_extract_all('这是一段中文 This is a passage in English
1234567', '(\\p{Han}+)(.+)');
+select regexp_extract_all('这是一段中文 This is a passage in English 1234567',
'(\\p{Han}+)(.+)');
+```
+
+```text
+------------------------------------------------------------------------------------------------+
| regexp_extract_all('这是一段中文 This is a passage in English 1234567',
'(\p{Han}+)(.+)') |
+------------------------------------------------------------------------------------------------+
@@ -155,7 +171,10 @@ SELECT REGEXP_EXTRACT_ALL('ABC', '(\\d+)');
emoji match
```sql
-mysql> SELECT REGEXP_EXTRACT_ALL('👩💻,👨🚀', '(💻|🚀)');
+SELECT REGEXP_EXTRACT_ALL('👩💻,👨🚀', '(💻|🚀)');
+```
+
+```text
+--------------------------------------------------------------+
| REGEXP_EXTRACT_ALL('👩💻,👨🚀', '(💻|🚀)') |
+--------------------------------------------------------------+
@@ -220,7 +239,10 @@ Error: missing ]: [[:alpha:]+
Advanced regexp
```sql
SELECT REGEXP_EXTRACT_ALL('ID:AA-1,ID:BB-2,ID:CC-3', '(?<=ID:)([A-Z]{2}-\\d)');
--- ERROR 1105 (HY000): errCode = 2, detailMessage =
(127.0.0.1)[INVALID_ARGUMENT]Invalid regex pattern: (?<=ID:)([A-Z]{2}-\d).
Error: invalid perl operator: (?<
+```
+
+```text
+ERROR 1105 (HY000): errCode = 2, detailMessage =
(127.0.0.1)[INVALID_ARGUMENT]Invalid regex pattern: (?<=ID:)([A-Z]{2}-\d).
Error: invalid perl operator: (?<
```
```sql
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/string-functions/regexp-extract-all-array.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/string-functions/regexp-extract-all-array.md
new file mode 100644
index 00000000000..1f5603a927e
--- /dev/null
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/string-functions/regexp-extract-all-array.md
@@ -0,0 +1,82 @@
+---
+{
+ "title": "REGEXP_EXTRACT_ALL_ARRAY",
+ "language": "zh-CN",
+ "description": "提取正则表达式第一个捕获组的全部匹配,返回字符串数组。"
+}
+---
+
+<version since="dev">
+
+</version>
+
+## 描述
+
+提取 `<pattern>` 的第一个捕获组在 `<str>` 中的全部非重叠匹配,并按匹配顺序返回真正的字符串数组。任一参数为 `NULL` 时返回
`NULL`。
+
+## 语法
+
+```sql
+REGEXP_EXTRACT_ALL_ARRAY(<str>, <pattern>)
+```
+
+## 参数
+
+| 参数 | 描述 |
+| --- | --- |
+| `<str>` | 用于匹配的字符串,类型为 `STRING`。 |
+| `<pattern>` | 正则表达式字符串,类型为 `STRING`。提取第一个捕获组;不支持第三个捕获组索引参数。 |
+
+## 返回值
+
+返回 `ARRAY<STRING>`。无匹配或表达式没有捕获组时返回空数组 `[]`;任一参数为 `NULL` 时返回 `NULL`。非法正则表达式会报错。
+
+默认使用 RE2 语法,匹配区分大小写。通过会话变量 `enable_extended_regex` 可启用高级正则特性,详见
[REGEXP_EXTRACT_ALL](./regexp-extract-all.md)。该函数返回数组;`REGEXP_EXTRACT_ALL`
返回格式化字符串。
+
+## 示例
+
+```sql
+SELECT regexp_extract_all_array('id=12,id=34', 'id=([0-9]+)') AS result;
+```
+
+```text
+["12", "34"]
+```
+
+使用 `(?i)` 忽略大小写:
+
+```sql
+SELECT regexp_extract_all_array('Hello hello HELLO', '(?i)(hello)') AS result;
+```
+
+```text
+["Hello", "hello", "HELLO"]
+```
+
+```sql
+SELECT regexp_extract_all_array('abc', '([0-9]+)') AS no_match,
+ regexp_extract_all_array('abc', 'abc') AS no_capture_group;
+```
+
+```text
+[] []
+```
+
+```sql
+SELECT regexp_extract_all_array(NULL, '(a)') AS null_input,
+ regexp_extract_all_array('a', NULL) AS null_pattern;
+```
+
+```text
+NULL NULL
+```
+
+返回值可直接交给数组函数:
+
+```sql
+SELECT array_size(regexp_extract_all_array('a1b2', '([0-9])')) AS matches;
+```
+
+```text
+2
+```
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/string-functions/regexp-extract-all.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/string-functions/regexp-extract-all.md
index 1c679966a7d..702f9d2ac3e 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/string-functions/regexp-extract-all.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/string-functions/regexp-extract-all.md
@@ -2,7 +2,7 @@
{
"title": "REGEXP_EXTRACT_ALL",
"language": "zh-CN",
- "description": "REGEXPEXTRACTALL 函数用于对给定字符串str执行正则表达式匹配,所有与指定 pattern
匹配的文本串当中的与第一个子模式匹配的部分。为了使函数返回表示模式匹配部分的字符串数组,该模式必须与输入字符串 str
的一部分完全匹配。如果没有匹配项,或模式不包含任何子模式,"
+ "description": "REGEXPEXTRACTALL 函数用于对给定字符串str执行正则表达式匹配,所有与指定 pattern
匹配的文本串当中的与第一个子模式匹配的部分。函数返回表示模式匹配部分的字符串,且该模式必须与输入字符串 str
的一部分完全匹配。如果没有匹配项,或模式不包含任何子模式,"
}
---
@@ -27,7 +27,7 @@ under the License.
## 描述
-REGEXP_EXTRACT_ALL 函数用于对给定字符串str执行正则表达式匹配,所有与指定 pattern
匹配的文本串当中的与第一个子模式匹配的部分。为了使函数返回表示模式匹配部分的字符串数组,该模式必须与输入字符串 str
的一部分完全匹配。如果没有匹配项,或模式不包含任何子模式,则返回空字符串。
+REGEXP_EXTRACT_ALL 函数用于对给定字符串str执行正则表达式匹配,所有与指定 pattern
匹配的文本串当中的与第一个子模式匹配的部分。函数返回表示模式匹配部分的字符串,且该模式必须与输入字符串 str
的一部分完全匹配。如果没有匹配项,或模式不包含任何子模式,则返回空字符串。
需要注意的是,在处理字符集匹配时,应使用 Utf-8 标准字符类。这确保函数能够正确识别和处理来自不同语言的各种字符。
@@ -49,13 +49,17 @@ REGEXP_EXTRACT_ALL(<str>, <pattern>)
## 参数
| 参数 | 描述 |
-| -- | -- |
+| --- | --- |
| `<str>` | 该参数为 String 类型。表示要执行正则表达式匹配的输入字符串。可以是字面值字符串或包含字符串数据的表列引用。|
| `<pattern>` | 该参数也为 String 类型。指定用于与输入字符串 <str>
匹配的正则表达式模式。该模式可以包含各种正则表达式构造,如字符类、量词和子模式。|
## 返回值
-函数返回表示输入字符串中与指定正则表达式的第一个子模式匹配部分的字符串数组。返回类型为 String
值数组。如果未找到匹配项,或模式没有子模式,则返回空数组。
+任一参数为 `NULL` 时返回 `NULL`。
+
+函数返回表示输入字符串中与指定正则表达式的第一个子模式匹配部分的字符串。返回类型为 String。如果未找到匹配项,或模式没有子模式,则返回空字符串。
+
+如需返回数组版本,请参见 [REGEXP_EXTRACT_ALL_ARRAY](./regexp-extract-all-array.md)。
**默认行为**:
@@ -84,12 +88,15 @@ REGEXP_EXTRACT_ALL(<str>, <pattern>)
| `(?U)` | 量词非贪婪:`*`、`+` 等尽可能少地匹配 |
| `(?-U)` | 量词贪婪(默认):`*`、`+` 等尽可能多地匹配 |
-## 例子
+## 示例 {#例子}
围绕 'C' 的小写字母基本匹配,在这个示例中,模式([[:lower:]]+)C([[:lower:]]+)匹配字符串中一个或多个小写字母后跟 'C'
再跟一个或多个小写字母的部分。'C' 之前的第一个子模式([[:lower:]]+)匹配 'b',因此结果为['b']。
```sql
-mysql> SELECT regexp_extract_all('AbCdE', '([[:lower:]]+)C([[:lower:]]+)');
+SELECT regexp_extract_all('AbCdE', '([[:lower:]]+)C([[:lower:]]+)');
+```
+
+```text
+--------------------------------------------------------------+
| regexp_extract_all('AbCdE', '([[:lower:]]+)C([[:lower:]]+)') |
+--------------------------------------------------------------+
@@ -99,7 +106,10 @@ mysql> SELECT regexp_extract_all('AbCdE',
'([[:lower:]]+)C([[:lower:]]+)');
字符串中的多个匹配项,在这里,模式在字符串中匹配两个部分。第一个匹配的第一个子模式匹配 'b',第二个匹配的第一个子模式匹配 'f'。因此结果为['b',
'f']。
```sql
-mysql> SELECT regexp_extract_all('AbCdEfCg', '([[:lower:]]+)C([[:lower:]]+)');
+SELECT regexp_extract_all('AbCdEfCg', '([[:lower:]]+)C([[:lower:]]+)');
+```
+
+```text
+-----------------------------------------------------------------+
| regexp_extract_all('AbCdEfCg', '([[:lower:]]+)C([[:lower:]]+)') |
+-----------------------------------------------------------------+
@@ -107,10 +117,13 @@ mysql> SELECT regexp_extract_all('AbCdEfCg',
'([[:lower:]]+)C([[:lower:]]+)');
+-----------------------------------------------------------------+
```
-从键值对中提取键, 该模式匹配字符串中的键值对。第一个子模式捕获键,因此结果为键的数组['abc', 'def', 'ghi']。
+从键值对中提取键, 该模式匹配字符串中的键值对。第一个子模式捕获键,因此结果为 ['abc', 'def', 'ghi']。
```sql
-mysql> SELECT regexp_extract_all('abc=111, def=222,
ghi=333','("[^"]+"|\\w+)=("[^"]+"|\\w+)');
+SELECT regexp_extract_all('abc=111, def=222,
ghi=333','("[^"]+"|\\w+)=("[^"]+"|\\w+)');
+```
+
+```text
+--------------------------------------------------------------------------------+
| regexp_extract_all('abc=111, def=222, ghi=333',
'("[^"]+"|\w+)=("[^"]+"|\w+)') |
+--------------------------------------------------------------------------------+
@@ -120,7 +133,10 @@ mysql> SELECT regexp_extract_all('abc=111, def=222,
ghi=333','("[^"]+"|\\w+)=("[
匹配汉字, 模式(\p{Han}+)(.+)首先通过第一个子模式(\p{Han}+)匹配一个或多个汉字,因此结果为['这是一段中文']。
```sql
-mysql> select regexp_extract_all('这是一段中文 This is a passage in English
1234567', '(\\p{Han}+)(.+)');
+select regexp_extract_all('这是一段中文 This is a passage in English 1234567',
'(\\p{Han}+)(.+)');
+```
+
+```text
+------------------------------------------------------------------------------------------------+
| regexp_extract_all('这是一段中文 This is a passage in English 1234567',
'(\p{Han}+)(.+)') |
+------------------------------------------------------------------------------------------------+
@@ -174,7 +190,10 @@ SELECT REGEXP_EXTRACT_ALL('ABC', '(\\d+)');
emoji字符匹配
```sql
-mysql> SELECT REGEXP_EXTRACT_ALL('👩💻,👨🚀', '(💻|🚀)');
+SELECT REGEXP_EXTRACT_ALL('👩💻,👨🚀', '(💻|🚀)');
+```
+
+```text
+--------------------------------------------------------------+
| REGEXP_EXTRACT_ALL('👩💻,👨🚀', '(💻|🚀)') |
+--------------------------------------------------------------+
@@ -239,7 +258,10 @@ Error: missing ]: [[:alpha:]+
高级的正则表达式
```sql
SELECT REGEXP_EXTRACT_ALL('ID:AA-1,ID:BB-2,ID:CC-3', '(?<=ID:)([A-Z]{2}-\\d)');
--- ERROR 1105 (HY000): errCode = 2, detailMessage =
(127.0.0.1)[INVALID_ARGUMENT]Invalid regex pattern: (?<=ID:)([A-Z]{2}-\d).
Error: invalid perl operator: (?<
+```
+
+```text
+ERROR 1105 (HY000): errCode = 2, detailMessage =
(127.0.0.1)[INVALID_ARGUMENT]Invalid regex pattern: (?<=ID:)([A-Z]{2}-\d).
Error: invalid perl operator: (?<
```
```sql
diff --git
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/string-functions/regexp-extract-all.md
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/string-functions/regexp-extract-all.md
index 1c679966a7d..2b19176d2b0 100644
---
a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/string-functions/regexp-extract-all.md
+++
b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/string-functions/regexp-extract-all.md
@@ -2,7 +2,7 @@
{
"title": "REGEXP_EXTRACT_ALL",
"language": "zh-CN",
- "description": "REGEXPEXTRACTALL 函数用于对给定字符串str执行正则表达式匹配,所有与指定 pattern
匹配的文本串当中的与第一个子模式匹配的部分。为了使函数返回表示模式匹配部分的字符串数组,该模式必须与输入字符串 str
的一部分完全匹配。如果没有匹配项,或模式不包含任何子模式,"
+ "description": "REGEXPEXTRACTALL 函数用于对给定字符串str执行正则表达式匹配,所有与指定 pattern
匹配的文本串当中的与第一个子模式匹配的部分。函数返回表示模式匹配部分的字符串,且该模式必须与输入字符串 str
的一部分完全匹配。如果没有匹配项,或模式不包含任何子模式,"
}
---
@@ -27,7 +27,7 @@ under the License.
## 描述
-REGEXP_EXTRACT_ALL 函数用于对给定字符串str执行正则表达式匹配,所有与指定 pattern
匹配的文本串当中的与第一个子模式匹配的部分。为了使函数返回表示模式匹配部分的字符串数组,该模式必须与输入字符串 str
的一部分完全匹配。如果没有匹配项,或模式不包含任何子模式,则返回空字符串。
+REGEXP_EXTRACT_ALL 函数用于对给定字符串str执行正则表达式匹配,所有与指定 pattern
匹配的文本串当中的与第一个子模式匹配的部分。函数返回表示模式匹配部分的字符串,且该模式必须与输入字符串 str
的一部分完全匹配。如果没有匹配项,或模式不包含任何子模式,则返回空字符串。
需要注意的是,在处理字符集匹配时,应使用 Utf-8 标准字符类。这确保函数能够正确识别和处理来自不同语言的各种字符。
@@ -49,13 +49,16 @@ REGEXP_EXTRACT_ALL(<str>, <pattern>)
## 参数
| 参数 | 描述 |
-| -- | -- |
+| --- | --- |
| `<str>` | 该参数为 String 类型。表示要执行正则表达式匹配的输入字符串。可以是字面值字符串或包含字符串数据的表列引用。|
| `<pattern>` | 该参数也为 String 类型。指定用于与输入字符串 <str>
匹配的正则表达式模式。该模式可以包含各种正则表达式构造,如字符类、量词和子模式。|
## 返回值
-函数返回表示输入字符串中与指定正则表达式的第一个子模式匹配部分的字符串数组。返回类型为 String
值数组。如果未找到匹配项,或模式没有子模式,则返回空数组。
+任一参数为 `NULL` 时返回 `NULL`。
+
+函数返回表示输入字符串中与指定正则表达式的第一个子模式匹配部分的字符串。返回类型为 String。如果未找到匹配项,或模式没有子模式,则返回空字符串。
+
**默认行为**:
@@ -84,12 +87,15 @@ REGEXP_EXTRACT_ALL(<str>, <pattern>)
| `(?U)` | 量词非贪婪:`*`、`+` 等尽可能少地匹配 |
| `(?-U)` | 量词贪婪(默认):`*`、`+` 等尽可能多地匹配 |
-## 例子
+## 示例 {#例子}
围绕 'C' 的小写字母基本匹配,在这个示例中,模式([[:lower:]]+)C([[:lower:]]+)匹配字符串中一个或多个小写字母后跟 'C'
再跟一个或多个小写字母的部分。'C' 之前的第一个子模式([[:lower:]]+)匹配 'b',因此结果为['b']。
```sql
-mysql> SELECT regexp_extract_all('AbCdE', '([[:lower:]]+)C([[:lower:]]+)');
+SELECT regexp_extract_all('AbCdE', '([[:lower:]]+)C([[:lower:]]+)');
+```
+
+```text
+--------------------------------------------------------------+
| regexp_extract_all('AbCdE', '([[:lower:]]+)C([[:lower:]]+)') |
+--------------------------------------------------------------+
@@ -99,7 +105,10 @@ mysql> SELECT regexp_extract_all('AbCdE',
'([[:lower:]]+)C([[:lower:]]+)');
字符串中的多个匹配项,在这里,模式在字符串中匹配两个部分。第一个匹配的第一个子模式匹配 'b',第二个匹配的第一个子模式匹配 'f'。因此结果为['b',
'f']。
```sql
-mysql> SELECT regexp_extract_all('AbCdEfCg', '([[:lower:]]+)C([[:lower:]]+)');
+SELECT regexp_extract_all('AbCdEfCg', '([[:lower:]]+)C([[:lower:]]+)');
+```
+
+```text
+-----------------------------------------------------------------+
| regexp_extract_all('AbCdEfCg', '([[:lower:]]+)C([[:lower:]]+)') |
+-----------------------------------------------------------------+
@@ -107,10 +116,13 @@ mysql> SELECT regexp_extract_all('AbCdEfCg',
'([[:lower:]]+)C([[:lower:]]+)');
+-----------------------------------------------------------------+
```
-从键值对中提取键, 该模式匹配字符串中的键值对。第一个子模式捕获键,因此结果为键的数组['abc', 'def', 'ghi']。
+从键值对中提取键, 该模式匹配字符串中的键值对。第一个子模式捕获键,因此结果为 ['abc', 'def', 'ghi']。
```sql
-mysql> SELECT regexp_extract_all('abc=111, def=222,
ghi=333','("[^"]+"|\\w+)=("[^"]+"|\\w+)');
+SELECT regexp_extract_all('abc=111, def=222,
ghi=333','("[^"]+"|\\w+)=("[^"]+"|\\w+)');
+```
+
+```text
+--------------------------------------------------------------------------------+
| regexp_extract_all('abc=111, def=222, ghi=333',
'("[^"]+"|\w+)=("[^"]+"|\w+)') |
+--------------------------------------------------------------------------------+
@@ -120,7 +132,10 @@ mysql> SELECT regexp_extract_all('abc=111, def=222,
ghi=333','("[^"]+"|\\w+)=("[
匹配汉字, 模式(\p{Han}+)(.+)首先通过第一个子模式(\p{Han}+)匹配一个或多个汉字,因此结果为['这是一段中文']。
```sql
-mysql> select regexp_extract_all('这是一段中文 This is a passage in English
1234567', '(\\p{Han}+)(.+)');
+select regexp_extract_all('这是一段中文 This is a passage in English 1234567',
'(\\p{Han}+)(.+)');
+```
+
+```text
+------------------------------------------------------------------------------------------------+
| regexp_extract_all('这是一段中文 This is a passage in English 1234567',
'(\p{Han}+)(.+)') |
+------------------------------------------------------------------------------------------------+
@@ -174,7 +189,10 @@ SELECT REGEXP_EXTRACT_ALL('ABC', '(\\d+)');
emoji字符匹配
```sql
-mysql> SELECT REGEXP_EXTRACT_ALL('👩💻,👨🚀', '(💻|🚀)');
+SELECT REGEXP_EXTRACT_ALL('👩💻,👨🚀', '(💻|🚀)');
+```
+
+```text
+--------------------------------------------------------------+
| REGEXP_EXTRACT_ALL('👩💻,👨🚀', '(💻|🚀)') |
+--------------------------------------------------------------+
@@ -239,7 +257,10 @@ Error: missing ]: [[:alpha:]+
高级的正则表达式
```sql
SELECT REGEXP_EXTRACT_ALL('ID:AA-1,ID:BB-2,ID:CC-3', '(?<=ID:)([A-Z]{2}-\\d)');
--- ERROR 1105 (HY000): errCode = 2, detailMessage =
(127.0.0.1)[INVALID_ARGUMENT]Invalid regex pattern: (?<=ID:)([A-Z]{2}-\d).
Error: invalid perl operator: (?<
+```
+
+```text
+ERROR 1105 (HY000): errCode = 2, detailMessage =
(127.0.0.1)[INVALID_ARGUMENT]Invalid regex pattern: (?<=ID:)([A-Z]{2}-\d).
Error: invalid perl operator: (?<
```
```sql
@@ -299,4 +320,4 @@ SELECT REGEXP_EXTRACT_ALL('aXbXcXd', '(a.*X)') AS greedy,
+----------+------------+
| ['aXbXcX'] | ['aX'] |
+----------+------------+
-```
\ No newline at end of file
+```
diff --git a/sidebars.ts b/sidebars.ts
index b8b827a525d..6bbd8c746e1 100644
--- a/sidebars.ts
+++ b/sidebars.ts
@@ -1612,6 +1612,7 @@ const sidebars: SidebarsConfig = {
'sql-manual/sql-functions/scalar-functions/string-functions/regexp-count',
'sql-manual/sql-functions/scalar-functions/string-functions/regexp-extract',
'sql-manual/sql-functions/scalar-functions/string-functions/regexp-extract-all',
+
'sql-manual/sql-functions/scalar-functions/string-functions/regexp-extract-all-array',
'sql-manual/sql-functions/scalar-functions/string-functions/regexp-extract-or-null',
'sql-manual/sql-functions/scalar-functions/string-functions/regexp-replace',
'sql-manual/sql-functions/scalar-functions/string-functions/regexp-replace-one',
diff --git
a/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/string-functions/regexp-extract-all.md
b/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/string-functions/regexp-extract-all.md
index 5786ec2a5d1..330cc5f6aee 100644
---
a/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/string-functions/regexp-extract-all.md
+++
b/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/string-functions/regexp-extract-all.md
@@ -8,7 +8,7 @@
## Description
-The `REGEXP_EXTRACT_ALL` function is used to perform a regular expression
match on a given string `str` and extract all the parts that match the first
sub - pattern of the specified `pattern`. For the function to return an array
of strings representing the matched parts of the pattern, the pattern must
exactly match a portion of the input string `str`. If there is no match, or if
the pattern does not contain any sub - patterns, an empty string is returned.
+The `REGEXP_EXTRACT_ALL` function is used to perform a regular expression
match on a given string `str` and extract all the parts that match the first
sub - pattern of the specified `pattern`. The function returns a string
representing the matched part of the pattern, and the pattern must exactly
match a portion of the input string `str`. If there is no match, or if the
pattern does not contain any sub - patterns, an empty string is returned.
It should be noted that when handling character set matching, Utf-8 standard
character classes should be used. This ensures that functions can correctly
identify and process various characters from different languages.
@@ -29,13 +29,16 @@ REGEXP_EXTRACT_ALL(<str>, <pattern>)
## Parameters
| Parameter | Description |
-| -- | -- |
+| --- | --- |
| `<str>` | This parameter is of type String. It represents the input string
on which the regular expression matching will be performed. This can be a
literal string value or a reference to a column in a table that contains string
data.|
| `<pattern>` | This parameter is also of type String. It specifies the
regular expression pattern that will be used to match against the input string
<str>. The pattern can include various regular expression constructs such as
character classes, quantifiers, and sub - patterns.|
## Return value
-The function returns an array of strings that represent the parts of the input
string that match the first sub - pattern of the specified regular expression.
The return type is an array of String values. If no matches are found, or if
the pattern has no sub - patterns, an empty array is returned.
+Returns `NULL` if either argument is `NULL`.
+
+The function returns a string that represents the part of the input string
that matches the first sub - pattern of the specified regular expression. The
return type is String. If no matches are found, or if the pattern has no sub -
patterns, an empty string is returned.
+
**Default Behavior**:
@@ -69,7 +72,10 @@ Pattern modifiers only take effect when using the default
regex engine. If `enab
Basic matching of lowercase letters around 'C'.In this example, the pattern
([[:lower:]]+)C([[:lower:]]+) matches the part of the string where one or more
lowercase letters are followed by 'C' and then one or more lowercase letters.
The first sub - pattern ([[:lower:]]+) before 'C' matches 'b', so the result is
['b'].
```sql
-mysql> SELECT regexp_extract_all('AbCdE', '([[:lower:]]+)C([[:lower:]]+)');
+SELECT regexp_extract_all('AbCdE', '([[:lower:]]+)C([[:lower:]]+)');
+```
+
+```text
+--------------------------------------------------------------+
| regexp_extract_all('AbCdE', '([[:lower:]]+)C([[:lower:]]+)') |
+--------------------------------------------------------------+
@@ -80,7 +86,10 @@ mysql> SELECT regexp_extract_all('AbCdE',
'([[:lower:]]+)C([[:lower:]]+)');
Multiple matches in a string. Here, the pattern matches two parts in the
string. The first match has the first sub - pattern matching 'b', and the
second match has the first sub - pattern matching 'f'. So the result is ['b',
'f'].
```sql
-mysql> SELECT regexp_extract_all('AbCdEfCg', '([[:lower:]]+)C([[:lower:]]+)');
+SELECT regexp_extract_all('AbCdEfCg', '([[:lower:]]+)C([[:lower:]]+)');
+```
+
+```text
+-----------------------------------------------------------------+
| regexp_extract_all('AbCdEfCg', '([[:lower:]]+)C([[:lower:]]+)') |
+-----------------------------------------------------------------+
@@ -88,10 +97,13 @@ mysql> SELECT regexp_extract_all('AbCdEfCg',
'([[:lower:]]+)C([[:lower:]]+)');
+-----------------------------------------------------------------+
```
-Extracting keys from key - value pairs.The pattern matches key - value pairs
in the string. The first sub - pattern captures the keys, so the result is an
array of the keys ['abc', 'def', 'ghi'].
+Extracting keys from key - value pairs.The pattern matches key - value pairs
in the string. The first sub - pattern captures the keys, so the result is
['abc', 'def', 'ghi'].
```sql
-mysql> SELECT regexp_extract_all('abc=111, def=222,
ghi=333','("[^"]+"|\\w+)=("[^"]+"|\\w+)');
+SELECT regexp_extract_all('abc=111, def=222,
ghi=333','("[^"]+"|\\w+)=("[^"]+"|\\w+)');
+```
+
+```text
+--------------------------------------------------------------------------------+
| regexp_extract_all('abc=111, def=222, ghi=333',
'("[^"]+"|\w+)=("[^"]+"|\w+)') |
+--------------------------------------------------------------------------------+
@@ -101,7 +113,10 @@ mysql> SELECT regexp_extract_all('abc=111, def=222,
ghi=333','("[^"]+"|\\w+)=("[
Matching Chinese characters.The pattern (\p{Han}+)(.+) first matches one or
more Chinese characters with the first sub - pattern (\p{Han}+), so the result
is ['这是一段中文'].
```sql
-mysql> select regexp_extract_all('这是一段中文 This is a passage in English
1234567', '(\\p{Han}+)(.+)');
+select regexp_extract_all('这是一段中文 This is a passage in English 1234567',
'(\\p{Han}+)(.+)');
+```
+
+```text
+------------------------------------------------------------------------------------------------+
| regexp_extract_all('这是一段中文 This is a passage in English 1234567',
'(\p{Han}+)(.+)') |
+------------------------------------------------------------------------------------------------+
@@ -155,7 +170,10 @@ SELECT REGEXP_EXTRACT_ALL('ABC', '(\\d+)');
emoji match
```sql
-mysql> SELECT REGEXP_EXTRACT_ALL('👩💻,👨🚀', '(💻|🚀)');
+SELECT REGEXP_EXTRACT_ALL('👩💻,👨🚀', '(💻|🚀)');
+```
+
+```text
+--------------------------------------------------------------+
| REGEXP_EXTRACT_ALL('👩💻,👨🚀', '(💻|🚀)') |
+--------------------------------------------------------------+
@@ -220,7 +238,10 @@ Error: missing ]: [[:alpha:]+
Advanced regexp
```sql
SELECT REGEXP_EXTRACT_ALL('ID:AA-1,ID:BB-2,ID:CC-3', '(?<=ID:)([A-Z]{2}-\\d)');
--- ERROR 1105 (HY000): errCode = 2, detailMessage =
(127.0.0.1)[INVALID_ARGUMENT]Invalid regex pattern: (?<=ID:)([A-Z]{2}-\d).
Error: invalid perl operator: (?<
+```
+
+```text
+ERROR 1105 (HY000): errCode = 2, detailMessage =
(127.0.0.1)[INVALID_ARGUMENT]Invalid regex pattern: (?<=ID:)([A-Z]{2}-\d).
Error: invalid perl operator: (?<
```
```sql
@@ -280,4 +301,4 @@ SELECT REGEXP_EXTRACT_ALL('aXbXcXd', '(a.*X)') AS greedy,
+----------+------------+
| ['aXbXcX'] | ['aX'] |
+----------+------------+
-```
\ No newline at end of file
+```
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]