shockme has asked for the wisdom of the Perl Monks concerning the following question:
I have the following example as an input file:
What I'm trying to do is pull the IP addresses out, and if a port is specified, pull that as well. (The port is anything following the / in the IP address).from 200.184.31.70/1713 to 168.49.127.83/80 on interface from 66.65.121.23/500 to 168.49.143.217/500 on interface from 208.40.56.131 to 168.49.123.100 on interface
I've come up with the following regex.
$inLine =~ /([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+(\/[0-9]+)?)[\w]*([0-9]+\.[ +0-9]+\.[0-9]+\.[0-9]+(\/[0-9]+)?)/
The problem seems to be where I am trying to specify the optional / and port. If anyone can point me in the right direction, I'd really appreciate it. I'm pretty sure I'm overlooking something simple.
Thanks!
If things get any worse, I'll have to ask you to stop helping me.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex for IP and Optional Port
by andye (Curate) on Jan 15, 2002 at 21:22 UTC | |
|
Re: Regex for IP and Optional Port
by dmmiller2k (Chaplain) on Jan 15, 2002 at 22:33 UTC | |
|
(tye)Re: Regex for IP and Optional Port
by tye (Sage) on Jan 16, 2002 at 00:02 UTC | |
|
(shockme) Re: Regex for IP and Optional Port
by shockme (Chaplain) on Jan 16, 2002 at 02:10 UTC | |
by spaz (Pilgrim) on Jan 17, 2002 at 04:03 UTC | |
|
Re: Regex for IP and Optional Port
by KILNA (Acolyte) on Jan 16, 2002 at 09:47 UTC | |
by KILNA (Acolyte) on Jan 16, 2002 at 09:54 UTC |