In keeping with TMTOWTDI, the following will correctly match an IPv4 address at the start of a scalar:
/^((\d{1,2}|1\d{2}|2[0-4]\d|25[0-5])\.){3}\2(\s|$) +/
And broken down (to make it look even more complicated):
/ (begin pattern match) ^ (match start of scalar) ( (begin grouping match of '0.' to '255.') ( (begin saving match of '0' to '255', to \2) \d{1,2}| (match '0' to '99' or...) 1\d{2}| (match '100' to '199' or...) 2[0-4]\d| (match '200' to '249' or...) 25[0-5] (match '250' to '255') ) (end saving match of '0' to '255', to \2) \. (match a '.') ) (end grouping match of '0.' to '255.') {3} (match '0.' to '255.' 3 times) \2 (match '0' to '255') (\s|$) (match whitespace or scalar end (when \n absent)) / (end pattern match)
======= BTW, that:
perl -le "s,,reverse killer,e,y,rifle,lycra,,print"
...is pretty /swe{3,}t/. :)
LaurenceHunter => "Life is loud, life is 60p/min."
In reply to Re: Clarify this Regular Expression
by Anonymous Monk
in thread Clarify this Regular Expression
by dru145
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |