On Wednesday, Oct 29, 2003, at 19:43 Europe/Brussels, Wiggins d Anconia wrote:
Doing it with plain regexp won't work in one go, you could put the above between (),(),() and check with $1,$2,$3 etc that you don't have an 894..
Rick Bragg wrote:than anHi,
I want to write a script that will test the contents of a file.
The file being tested will pass only if it contains nothing moreip address on one line. Does anyone have a sample of a simple regex to
accomplish this?
/\d+\.\d+\.\d+\.\d+\n?/s
Beware of insufficient regexes in regex clothing. The above will certainly find one or more digits followed by a dot, followed by one or more digits followed by a dot, etc. But it does *NOT* match an IP address...
/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/
Is at least closer, but it is still not sufficient, as IP addresses are
bounded, I believe, at 255 so 336.47.894.0, will match the above, but is
not a valid IP address.
How strict do you need to be, how sure are you about the data in the files?
However, you could also use Regexp::Common
Jerry
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]