| От | Bruno Wolff III |
|---|---|
| Тема | Re: Negative lookbehind assertions in regexs |
| Дата | |
| Msg-id | 20050829162103.GA32443@wolff.to обсуждение исходный текст |
| Ответ на | Negative lookbehind assertions in regexs ("Julian Scarfe" <julian@avbrief.com>) |
| Список | pgsql-sql |
On Mon, Aug 29, 2005 at 14:11:37 +0100, Julian Scarfe <julian@avbrief.com> wrote:
> I'd like a regex that matches 'CD' but not 'ABCD' in any part of the regex.
>
> Is there a workaround that allows me to do this as a single regex?
>
> I know I could and together a ~ and !~ like this
>
> # select ('CD' ~ 'CD') and ('CD' !~ 'ABCD');
> ?column?
> ----------
> t
> (1 row)
>
> # select ('ABCD' ~ 'CD') and ('ABCD' !~ 'ABCD');
> ?column?
> ----------
> f
> (1 row)
The above code won't work because there could be both CD and ABCD in the
string. What you want to do is match all of the valid possibilities.
Something like:
(^.?CD)|([^B]CD)|([^A]BCD)
В списке pgsql-sql по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера