pgsql-sql-owner@postgresql.org wrote:
> for Reverse DNS purposes, I'd like to reverse an IP ...
>
> ie: 200.46.204.1 would become 1.204.46.200
>
> Is there an easy way of doing this *short* of writing a
> plpgsql function?
>
> I've checked the docs, and found the substring() function
> that allows for using a regex, which I thought might allow
> this, but can't seem to figure out a proper format for it ;(
>
> If I have to write a function to do it, fine ... just wanted
> to make sure I wasn't missing something first ...
Hi,
You can use (\d+)\.(\d+)\.(\d+)\.(\d+) for the match, and \4.\3.\2.\1 for the replacement in your Regexp.
Cheers,
----------------------------------
Philippe Lang, Ing. Dipl. EPFL
Attik System
rte de la Fonderie 2
1700 Fribourg
Switzerland
http://www.attiksystem.ch
Tel: +41 (26) 422 13 75
Fax: +41 (26) 422 13 76