From 49945da762ef47011b0e19a72b52ff18c27477d3 Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Wed, 21 Dec 2016 01:22:57 +0000 Subject: [PATCH 1/3] [TRAFODION-2403] update sql reference manual about REGEXP function --- .../_chapters/sql_language_elements.adoc | 58 ++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/docs/sql_reference/src/asciidoc/_chapters/sql_language_elements.adoc b/docs/sql_reference/src/asciidoc/_chapters/sql_language_elements.adoc index 535286fbf5..2ce2a2a403 100644 --- a/docs/sql_reference/src/asciidoc/_chapters/sql_language_elements.adoc +++ b/docs/sql_reference/src/asciidoc/_chapters/sql_language_elements.adoc @@ -2511,6 +2511,8 @@ subquery is empty, the predicate is false. | <> | Determines if a sequence of values is equal to any of the sequences of values in a list of sequences. | <> | Searches for character strings that match a pattern. +| <> | Searches for character strings that match a pattern, The pattern +can be an extended regular expression. | <> | Determines whether all the values in a sequence of values are null. | <> + (ALL, ANY, SOME ) | Compares the values of sequences of expressions to the values in each @@ -3334,7 +3336,7 @@ trailing blank) will not be located by LIKE '%MB' but will be located by LIKE '%MB%'. [[like_examples]] -=== Examples +==== Examples * Find all employee last names beginning with ZE: + @@ -3351,6 +3353,60 @@ partdesc NOT LIKE 'FLOPPY\_DISK' ESCAPE '\' The escape character indicates that the underscore in 'FLOPPY_DISK' is part of the string to search for, not a wild-card character. +<<< +[[regexp_predicate]] +=== REGEXP Predicate + +Performs a pattern match of a string expression against a pattern . +The pattern can be an extended regular expression. +Returns 1 if expression matches pattern; otherwise it returns 0. +If either expression or pattern is NULL, the result is NULL. + +[[regexp_syntax]] +==== Syntax +``` +match-value [NOT] REGEXP pattern +``` + +* `_match-value_` ++ +is a character value expression that specifies a set of strings to +search for that match the _pattern_. + +* `_pattern_` ++ +is a character value expression that specifies the pattern string for +the search in form of Regular Expression. +The Trafodion Regular Expression is following the POSIX regular expression rules. + + +[[using_not]] +===== Using NOT + +If you specify NOT, the predicate is true if the _pattern_ does not +match any string in the _match-value_. + +[[regexp_examples]] +==== Examples + +* Find valid numbers ++ +``` +col REGEXP '^[0-9]*\s*$' +``` + +* Find valid words, no numbers ++ +``` +col REGEXP '^.[A-Za-z]+\s*$' +``` + +* Find valid email address ++ +``` +col REGEXP '\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*\s*' +``` + <<< [[null_predicate]] === NULL Predicate From 0273bbbceb7e750861fb735916500c10af31758f Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Thu, 22 Dec 2016 12:09:31 +0000 Subject: [PATCH 2/3] [TRAFODION-2403] update according review comments --- .../src/asciidoc/_chapters/sql_language_elements.adoc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/docs/sql_reference/src/asciidoc/_chapters/sql_language_elements.adoc b/docs/sql_reference/src/asciidoc/_chapters/sql_language_elements.adoc index 2ce2a2a403..b6dc10ceea 100644 --- a/docs/sql_reference/src/asciidoc/_chapters/sql_language_elements.adoc +++ b/docs/sql_reference/src/asciidoc/_chapters/sql_language_elements.adoc @@ -2511,8 +2511,7 @@ subquery is empty, the predicate is false. | <> | Determines if a sequence of values is equal to any of the sequences of values in a list of sequences. | <> | Searches for character strings that match a pattern. -| <> | Searches for character strings that match a pattern, The pattern -can be an extended regular expression. +| <> | Searches for character strings that match an extended regular expression. | <> | Determines whether all the values in a sequence of values are null. | <> + (ALL, ANY, SOME ) | Compares the values of sequences of expressions to the values in each @@ -3365,7 +3364,7 @@ If either expression or pattern is NULL, the result is NULL. [[regexp_syntax]] ==== Syntax ``` -match-value [NOT] REGEXP pattern +match-value [NOT] REGEXP regular-expression ``` * `_match-value_` @@ -3375,9 +3374,8 @@ search for that match the _pattern_. * `_pattern_` + -is a character value expression that specifies the pattern string for -the search in form of Regular Expression. -The Trafodion Regular Expression is following the POSIX regular expression rules. +is a character value expression that specifies a regular expression. +Trafodion regular expressions follow POSIX regular expression rules. [[using_not]] From bca9aa48ae30f322c93de2c2b8d9f21f31d750a7 Mon Sep 17 00:00:00 2001 From: Liu Ming Date: Fri, 23 Dec 2016 09:10:48 +0000 Subject: [PATCH 3/3] [TRAFODION-2403] fix typos --- .../src/asciidoc/_chapters/sql_language_elements.adoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/sql_reference/src/asciidoc/_chapters/sql_language_elements.adoc b/docs/sql_reference/src/asciidoc/_chapters/sql_language_elements.adoc index b6dc10ceea..fde124d528 100644 --- a/docs/sql_reference/src/asciidoc/_chapters/sql_language_elements.adoc +++ b/docs/sql_reference/src/asciidoc/_chapters/sql_language_elements.adoc @@ -3370,9 +3370,9 @@ match-value [NOT] REGEXP regular-expression * `_match-value_` + is a character value expression that specifies a set of strings to -search for that match the _pattern_. +search for that match the _regular-expression_. -* `_pattern_` +* `_regular-expression_` + is a character value expression that specifies a regular expression. Trafodion regular expressions follow POSIX regular expression rules. @@ -3381,7 +3381,7 @@ Trafodion regular expressions follow POSIX regular expression rules. [[using_not]] ===== Using NOT -If you specify NOT, the predicate is true if the _pattern_ does not +If you specify NOT, the predicate is true if the _regular-expression_ does not match any string in the _match-value_. [[regexp_examples]]