ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > Living Room

Regexp help

<< < (3/3)

Renegade:
Yeah... generally you can be pretty sloppy when checking for IP addresses though as they're unlikely to be reported badly, and few other strings will match improperly, e.g. version numbering with major, minor, revision, and build -- 10.23.34.987.

Here are some URLs for regex to actually do IP addresses properly:

http://www.shellhacks.com/en/RegEx-Find-IP-Addresses-in-a-File-Using-Grep

http://www.mkyong.com/regular-expressions/how-to-validate-ip-address-with-regular-expression/

http://stackoverflow.com/questions/15875013/extract-ip-addresses-from-strings-using-regex

They're kind of ugly with a lot of pipes.

@4wd - Your regex there is elegant and terse. It's one of the things that I tend to avoid as I find it's simply easier to read when being a bit more verbose. I also try to avoid a lot of special matching characters as in general as a lot of the regex I use are in EditPlus, and it's not really the best there, so it encourages being verbose rather than elegant.

4wd:
@4wd - Your regex there is elegant and terse.-Renegade (November 04, 2014, 09:25 PM)
--- End quote ---

The IP bit wasn't mine, it came from here.

It's one of the things that I tend to avoid as I find it's simply easier to read when being a bit more verbose.
--- End quote ---

Conversely, I find the opposite :)

I have more chance of understanding it if I'm not going cross-eyed trying to take in 50+ characters at once ;D

Navigation

[0] Message Index

[*] Previous page

Go to full version