pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedWay to reverse ordering of an IP ... ?
2+ messages / 2 participants
[nested] [flat]
* Way to reverse ordering of an IP ... ?
@ 2006-09-06 03:51 Marc G. Fournier <scrappy@postgresql.org>
0 siblings, 0 replies; 2+ messages in thread
From: Marc G. Fournier @ 2006-09-06 03:51 UTC (permalink / raw)
To: pgsql-sql
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 ...
----
Marc G. Fournier Hub.Org Networking Services (http://www.hub.org)
Email . scrappy@hub.org MSN . scrappy@hub.org
Yahoo . yscrappy Skype: hub.org ICQ . 7615664
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Way to reverse ordering of an IP ... ?
@ 2006-09-06 06:35 Philippe Lang <philippe.lang@attiksystem.ch>
0 siblings, 0 replies; 2+ messages in thread
From: Philippe Lang @ 2006-09-06 06:35 UTC (permalink / raw)
To: Marc G. Fournier <scrappy@postgresql.org>; pgsql-sql
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
Attachments:
smime.p7s (application/x-pkcs7-signature, 3.1K) download
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2006-09-06 06:35 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-09-06 03:51 Way to reverse ordering of an IP ... ? Marc G. Fournier <scrappy@postgresql.org>
2006-09-06 06:35 Re: Way to reverse ordering of an IP ... ? Philippe Lang <philippe.lang@attiksystem.ch>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox