Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^3: Match zero times in regex

by AnomalousMonk (Archbishop)
on Dec 13, 2011 at 05:02 UTC ( [id://943246]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Match zero times in regex
in thread Match zero times in regex

From the OP:

... if the entry is
    permit iphost 10.11.1.1 192.168.100.0 0.0.0.255
I want to pull out
    192.168.100.0 0.0.0.255
but if the entry is
    permit ip10.11.1.0  0.0.0.255 192.168.100.0 0.0.0.255
I want to pull out
10.11.1.0  0.0.0.255
    192.168.100.0 0.0.0.255

I don't see how an IP (10.11.1.1 in the example) after 'host' is ever desired to be captured. Am I missing something (wouldn't be the first time)?

Replies are listed 'Best First'.
Re^4: Match zero times in regex
by ikegami (Patriarch) on Dec 17, 2011 at 09:20 UTC

    I don't see how an IP (10.11.1.1 in the example) after 'host' is ever desired to be captured.

    Exactly, yet I showed that your code does capture it.

      Am I missing something ...?

      I went back and tried the exact strings of your counter-example (at first, I thought you were (mis-)quoting something, but couldn't figure out what it was) and I finally see your point: if there are two or more whitespaces between 'host' and the immediately following IP, then that IP will not be excluded because there is a position in the string that is followed by one or more whitespaces and is preceded by something that is not 'host', i.e., by one or more whitespaces.

      OK, got it at last!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://943246]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-23 21:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found