This commit is contained in:
Alexander Gololobov 2023-02-17 13:41:38 +01:00
parent 706db7cca2
commit 8b6b86eb8c
2 changed files with 49 additions and 0 deletions

View File

@ -1,38 +1,85 @@
-- { echoOn }
select regexpExtract('100-200', '(\\d+)-(\\d+)', 1);
100 100
select regexpExtract('100-200', '(\\d+)-(\\d+)');
100 100
select regexpExtract('100-200', '(\\d+)-(\\d+)', 2);
200 200
select regexpExtract('100-200', '(\\d+)-(\\d+)', 0);
100-200 100-200
select regexpExtract('100-200', '(\\d+).*', 1);
100 100
select regexpExtract('100-200', '([a-z])', 1);
select regexpExtract(null, '([a-z])', 1);
\N \N
select regexpExtract('100-200', null, 1);
\N \N
select regexpExtract('100-200', '([a-z])', null);
\N \N
select REGEXP_EXTRACT('100-200', '(\\d+)-(\\d+)', 1);
100 100
select REGEXP_EXTRACT('100-200', '(\\d+)-(\\d+)');
100 100
select REGEXP_EXTRACT('100-200', '(\\d+)-(\\d+)', 0);
100-200 100-200
select regexpExtract('0123456789', '(\d+)(\d+)', 0);
0123456789 0123456789
select regexpExtract('0123456789', '(\d+)(\d+)', 1);
012345678 012345678
select regexpExtract('0123456789', '(\d+)(\d+)', 2);
9 9
select regexpExtract(materialize('100-200'), '(\\d+)-(\\d+)');
100 100
select regexpExtract(materialize('100-200'), '(\\d+)-(\\d+)', 1);
100 100
select regexpExtract(materialize('100-200'), '(\\d+)-(\\d+)', 2);
200 200
select regexpExtract(materialize('100-200'), '(\\d+).*', 1);
100 100
select regexpExtract(materialize('100-200'), '([a-z])', 1);
select regexpExtract(materialize(null), '([a-z])', 1);
\N \N
select regexpExtract(materialize('100-200'), null, 1);
\N \N
select regexpExtract(materialize('100-200'), '([a-z])', null);
\N \N
select regexpExtract('100-200', '(\\d+)-(\\d+)', materialize(1));
100 100
select regexpExtract('100-200', '(\\d+)-(\\d+)', materialize(2));
200 200
select regexpExtract('100-200', '(\\d+).*', materialize(1));
100 100
select regexpExtract('100-200', '([a-z])', materialize(1));
select regexpExtract(null, '([a-z])', materialize(1));
\N \N
select regexpExtract('100-200', null, materialize(1));
\N \N
select regexpExtract('100-200', '([a-z])', materialize(null));
\N \N
select regexpExtract(materialize('100-200'), '(\\d+)-(\\d+)', materialize(1));
100 100
select regexpExtract(materialize('100-200'), '(\\d+)-(\\d+)', materialize(2));
200 200
select regexpExtract(materialize('100-200'), '(\\d+).*', materialize(1));
100 100
select regexpExtract(materialize('100-200'), '([a-z])', materialize(1));
select regexpExtract(materialize(null), '([a-z])', materialize(1));
\N \N
select regexpExtract(materialize('100-200'), null, materialize(1));
\N \N
select regexpExtract(materialize('100-200'), '([a-z])', materialize(null));
\N \N
select regexpExtract('100-200'); -- { serverError NUMBER_OF_ARGUMENTS_DOESNT_MATCH }
select regexpExtract('100-200', '(\\d+)-(\\d+)', 1, 2); -- { serverError NUMBER_OF_ARGUMENTS_DOESNT_MATCH }
select regexpExtract(cast('100-200' as FixedString(10)), '(\\d+)-(\\d+)', 1); -- { serverError ILLEGAL_TYPE_OF_ARGUMENT }
select regexpExtract('100-200', cast('(\\d+)-(\\d+)' as FixedString(20)), 1); -- { serverError ILLEGAL_TYPE_OF_ARGUMENT }
select regexpExtract('100-200', materialize('(\\d+)-(\\d+)'), 1); -- { serverError ILLEGAL_COLUMN }
select regexpExtract('100-200', '(\\d+)-(\\d+)', 3); -- { serverError INDEX_OF_POSITIONAL_ARGUMENT_IS_OUT_OF_RANGE }
select regexpExtract('100-200', '(\\d+)-(\\d+)', -1); -- { serverError INDEX_OF_POSITIONAL_ARGUMENT_IS_OUT_OF_RANGE }
select regexpExtract('100-200', '\\d+-\\d+', 0);
100-200 100-200
select regexpExtract('100-200', '\\d+-\\d+', 1);-- { serverError INDEX_OF_POSITIONAL_ARGUMENT_IS_OUT_OF_RANGE }

View File

@ -1,3 +1,4 @@
-- { echoOn }
select regexpExtract('100-200', '(\\d+)-(\\d+)', 1); select regexpExtract('100-200', '(\\d+)-(\\d+)', 1);
select regexpExtract('100-200', '(\\d+)-(\\d+)'); select regexpExtract('100-200', '(\\d+)-(\\d+)');
select regexpExtract('100-200', '(\\d+)-(\\d+)', 2); select regexpExtract('100-200', '(\\d+)-(\\d+)', 2);
@ -51,3 +52,4 @@ select regexpExtract('100-200', '(\\d+)-(\\d+)', 3); -- { serverError INDEX_OF_P
select regexpExtract('100-200', '(\\d+)-(\\d+)', -1); -- { serverError INDEX_OF_POSITIONAL_ARGUMENT_IS_OUT_OF_RANGE } select regexpExtract('100-200', '(\\d+)-(\\d+)', -1); -- { serverError INDEX_OF_POSITIONAL_ARGUMENT_IS_OUT_OF_RANGE }
select regexpExtract('100-200', '\\d+-\\d+', 0); select regexpExtract('100-200', '\\d+-\\d+', 0);
select regexpExtract('100-200', '\\d+-\\d+', 1);-- { serverError INDEX_OF_POSITIONAL_ARGUMENT_IS_OUT_OF_RANGE } select regexpExtract('100-200', '\\d+-\\d+', 1);-- { serverError INDEX_OF_POSITIONAL_ARGUMENT_IS_OUT_OF_RANGE }
-- { echoOff }