Re: back references using regex

Поиск
Список
Период
Сортировка
От Michael Fuhr
Тема Re: back references using regex
Дата
Msg-id 20050910132338.GB45586@winnie.fuhr.org
обсуждение исходный текст
Ответ на Re: back references using regex  (Matthew Peter <survivedsushi@yahoo.com>)
Список pgsql-general
On Fri, Sep 09, 2005 at 10:11:46PM -0700, Matthew Peter wrote:
> One other thing, when I wrote back I actually used
> 34.31.29.20 (random), not 12.00.00.34 like i showed in
> the example, which is why i said it didn't work on
> digits.

When posting examples, please post something you actually tried so
other people can see exactly what you're doing and attempt to
duplicate your results.  Little differences sometimes matter, as
this case illustrates.

> SELECT substring('34.31.29.20' FROM $$((\w+)\.\2)$$);
>   substring
>  -----------
>
>  (1 row)
>
> little did i know writing it with 12.00.00.34 would
> return 00.00... so yes, that did suprise me.
> Apparently only using the identical values returns a
> value.

That's what a back reference is: it means "match the same value you
matched before," not just anything that matches the same regular
expression.

Usenet junkies might find it amusing to use back references to
search their new server's list of newsgroups:

egrep '([^.]+)\.\1\.\1' newsgroups

--
Michael Fuhr

В списке pgsql-general по дате отправления:

Предыдущее
От: Douglas McNaught
Дата:
Сообщение: Re: back references using regex
Следующее
От: Tom Lane
Дата:
Сообщение: Re: ERROR: type "temp_gc" already exists