|We don't bite newbies here... much|
Parenthesis grouping into regexes.by aramisf (Beadle)
|on Apr 25, 2012 at 20:58 UTC||Need Help??|
aramisf has asked for the
wisdom of the Perl Monks concerning the following question:
I was writing a script to filter ip addresses. And used two (simple and incomplete) regexes:
They aren't (and don't need to be) fully correct. I understand that these regexes match an invalid ips like 999.888.777.666, but the ips I have on the list are ok.
My question resides here:
It is intented to catch and ip address, followed or not by a prefix. But the resulting match does not catch the prefix:
I don't understand how could one use the groups inside two or three levels into parenthesis.
Considering this situation, how the matches are set into $1, $2... variables?
### Update ###
There was a little problem about my english, sorry about that. Where I typed 'mask' I wanted to mean 'prefix' (the '/\d\d' part of an ip address). Maybe this is what Kenosis asked (if I understand the question).