in reply to Re^4: Seeker of Regex Wisdom (strings which don't form specific patterns)
in thread Seeker of Regex Wisdom (strings which don't form specific patterns)
Unfortunately, capture groups don't change their numbering under a counted quantifier
One way to overcome that is keeping track oneself:
$_ = '192.168.2.111'; my @l; /^(?:([01]?\d\d?|2[0-4]\d|25[0-5])(?{push@l,$1})\.){3}([01]?\d\d?|2[0- +4]\d|25[0-5])$/; print join('-',@l,$2),"\n"; __END__ 192-168-2-111
|
|---|