| От | Tom Lane |
|---|---|
| Тема | Re: [DOCS] can't be both non-capturing and still capture |
| Дата | |
| Msg-id | 25895.1499134203@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | [DOCS] can't be both non-capturing and still capture (srn@coolheads.com) |
| Список | pgsql-docs |
srn@coolheads.com writes:
> Here, the whole regexp is non-capturing, right, so how can the result be
> reported as shown?
No, the outer parens are non-capturing, but the ones inside them still
are capturing parens.
Perhaps it would clarify matters if you tried it with plain outer parens:
=# SELECT regexp_matches('abc01234xyz', '((.*?)(\d+)(.*)){1,1}');
regexp_matches
-----------------------------
{abc01234xyz,abc,01234,xyz}
(1 row)
In this case we get a report from each of the four sets of capturing
parens. Or another example:
=# SELECT regexp_matches('abc01234xyz', '((?:.*?)(\d+)(.*)){1,1}');
regexp_matches
-------------------------
{abc01234xyz,01234,xyz}
(1 row)
Outer parens capture, first inner set don't, other two inner sets do.
regards, tom lane
В списке pgsql-docs по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера