Cylar Z wrote:
Hey programming gurus...
I want to write a script which takes a block of text
and extracts any numbers which match a 123.456.789.012
pattern. I am not looking for any numbers in
particular (so I don't think the grep command will be
of much help) but rather, any set of numbers that
looks like an IP address.
Why /not/ grep?
egrep -o '\<[0-9]{1,3}(\.[0-9]{1,3}){3}\>'
does a decent job, though it will match invalid components like your 456
or 789 above. A more thorough regex could be constructed to match
exactly 0-255, but it's somewhat painful.
--
HTH,
Micah J. Cowan
Programmer, musician, typesetting enthusiast, gamer...
http://micah.cowan.name/
_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech