mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
Add current substring regular expression syntax
SQL:1999 had syntax SUBSTRING(text FROM pattern FOR escapechar) but this was replaced in SQL:2003 by the more clear SUBSTRING(text SIMILAR pattern ESCAPE escapechar) but this was never implemented in PostgreSQL. This patch adds that new syntax as an alternative in the parser, and updates documentation and tests to indicate that this is the preferred alternative now. Reviewed-by: Pavel Stehule <pavel.stehule@gmail.com> Reviewed-by: Vik Fearing <vik@postgresfriends.org> Reviewed-by: Fabien COELHO <coelho@cri.ensmp.fr> Discussion: https://www.postgresql.org/message-id/flat/a15db31c-d0f8-8ce0-9039-578a31758adb%402ndquadrant.com
This commit is contained in:
@ -564,7 +564,7 @@ SELECT substring('alphabet'::citext, 3, 2) = 'ph' AS t;
|
||||
SELECT substring('Thomas'::citext from 2 for 3) = 'hom' AS t;
|
||||
SELECT substring('Thomas'::citext from 2) = 'homas' AS t;
|
||||
SELECT substring('Thomas'::citext from '...$') = 'mas' AS t;
|
||||
SELECT substring('Thomas'::citext from '%#"o_a#"_' for '#') = 'oma' AS t;
|
||||
SELECT substring('Thomas'::citext similar '%#"o_a#"_' escape '#') = 'oma' AS t;
|
||||
|
||||
SELECT trim(' trim '::citext) = 'trim' AS t;
|
||||
SELECT trim('xxxxxtrimxxxx'::citext, 'x'::citext) = 'trim' AS t;
|
||||
|
Reference in New Issue
Block a user