Minor changes in splitByRegexp

This commit is contained in:
Vladimir 2021-05-13 12:21:00 +03:00 committed by GitHub
parent 452dec891d
commit 7c77dd1e21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 8 deletions

View File

@ -109,22 +109,22 @@ splitByRegexp(<regexp>, <s>)
Returns an array of selected substrings. Empty substrings may be selected when: Returns an array of selected substrings. Empty substrings may be selected when:
Type: [Array](../../sql-reference/data-types/array.md) of [String](../../sql-reference/data-types/string.md).
- A non-empty regular expression match occurs at the beginning or end of the string; - A non-empty regular expression match occurs at the beginning or end of the string;
- There are multiple consecutive non-empty regular expression matches; - There are multiple consecutive non-empty regular expression matches;
- The original string `s` is empty while the regular expression is not empty. - The original string `s` is empty while the regular expression is not empty.
Type: [Array](../../sql-reference/data-types/array.md) of [String](../../sql-reference/data-types/string.md).
**Example** **Example**
``` sql ``` sql
SELECT splitByRegexp('\\d+', 'a1bc2de3f') SELECT splitByRegexp('\\d+', 'a12bc23de345f')
``` ```
``` text ``` text
┌─splitByRegexp('\\d+', 'a1bc2de3f')─┐ ┌─splitByRegexp('\\d+', 'a12bc23de345f')─┐
│ ['a','bc','de','f'] │ │ ['a','bc','de','f']
└────────────────────────────────────┘ └────────────────────────────────────────
``` ```
``` sql ``` sql
@ -196,4 +196,3 @@ Result:
│ [['abc','123'],['8','"hkl"']] │ │ [['abc','123'],['8','"hkl"']] │
└───────────────────────────────────────────────────────────────────────┘ └───────────────────────────────────────────────────────────────────────┘
``` ```

View File

@ -1,4 +1,4 @@
select splitByRegexp('\\d+', 'a1ba5ba8b'); select splitByRegexp('\\d+', x) from (select arrayJoin(['a1ba5ba8b', 'a11ba5689ba891011b']) x);
select splitByRegexp('', 'abcde'); select splitByRegexp('', 'abcde');
select splitByRegexp('<[^<>]*>', x) from (select arrayJoin(['<h1>hello<h2>world</h2></h1>', 'gbye<split>bug']) x); select splitByRegexp('<[^<>]*>', x) from (select arrayJoin(['<h1>hello<h2>world</h2></h1>', 'gbye<split>bug']) x);
select splitByRegexp('ab', ''); select splitByRegexp('ab', '');