Re: PostgreSQL 9.3.5 substring(text from pattern for escape) bug
От | Daniel Verite |
---|---|
Тема | Re: PostgreSQL 9.3.5 substring(text from pattern for escape) bug |
Дата | |
Msg-id | 785708a0-a64c-42ee-9173-f596c1fc92ec@manitou-mail.org обсуждение исходный текст |
Ответ на | PostgreSQL 9.3.5 substring(text from pattern for escape) bug (Robert Schreiber <bobschreiber@charter.net>) |
Ответы |
Re: PostgreSQL 9.3.5 substring(text from pattern for escape) bug
|
Список | pgsql-bugs |
Robert Schreiber wrote: > My understand of this is: > Q? -- matches 0 or 1 occurrences of Q (the leading one, if present) > #" -- starts data collection > % -- matches any number of characters > #" -- ends data collection > Q? -- matches 0 or 1 occurrences of Q (the trialing one, if present) > > What appears to be happening is that the _Q? on the tail_ is being > matched, but _the Q is also being included in the collected data.__ The expression as a whole is being matched, otherwise this form of substring() would return NULL, as told in https://www.postgresql.org/docs/current/functions-matching.html : "As with SIMILAR TO, the specified pattern must match the entire data string, or else the function fails and returns null. " Considering your example, where 'My Q NameQ' is the string and 'Q?#"%#"Q?' the regexp. The engine can either see the ending 'Q' as part of the % match, or as a match for the 'Q?' that follows. Both cases are valid matches. You seem to expect that % must be non-greedy and let the final Q? match 1 Q instead of 0, but there doesn't appear to be anything in the doc that supports this interpretation. In fact, it mentions that "%" is comparable to ".*" in POSIX regular expressions, and the latter _is_ greedy. Best regards, -- Daniel Vérité PostgreSQL-powered mailer: http://www.manitou-mail.org Twitter: @DanielVerite
В списке pgsql-bugs по дате отправления: