Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Trimming IP Addresses

Re: Trimming IP Addresses

From: Vladimir M. Zakharychev <vladimir.zakharychev_at_gmail.com>
Date: 8 Jun 2006 08:59:38 -0700
Message-ID: <1149782378.130654.79510@u72g2000cwu.googlegroups.com>


jhulst wrote:
> Hello,
> I am looking for a function that will allow me to trim off the right
> octet of an ip address. ie. go from 192.168.1.255 to 192.168.1
> I tried using a rtrim function using a wildcard such as
> rtrim(ipaddress, '.%') but it doesn't give me anything. Any help or
> advice would be much appreciated.
>
> Thanks,
> Josh

In 10g and later, you can use REGEXP_SUBSTR():

RTRIM(REGEXP_SUBSTR(:ip_address,'^([0-9]\.){3}'),'.')

In all releases you can use a combination of INSTR() and SUBSTR():

SUBSTR(:ip_address,1,INSTR(:ip_address,'.'-1)-1)

Hth,

    Vladimir M. Zakharychev
    N-Networks, makers of Dynamic PSP(tm)     http://www.dynamicpsp.com Received on Thu Jun 08 2006 - 10:59:38 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US