G'day ilcylic,
While it may be possible to use 'grep -P ...', I suspect using 'perl ...' (on the command line) would be a lot simpler.
Regexp::Common provides often-used regexes; Regexp::Common::net has regexes for IP addresses.
Using this module, I'd eliminate lines matching /^$RE{net}{IPv4}/ first; then attempt to match /^\S+\s+.*?$RE{net}{IPv4}/.
For use on the command line:
$ perl -MRegexp::Common=net -wnE '/^$RE{net}{IPv4}/ and next; /^\S+\s+ +.*?$RE{net}{IPv4}/ and say' 127.0.0.1aaa 127.0.0.1 256.0.0.1aaa 127.0.0.1 256.0.0.1aaa 127.0.0.1 aaa 127.0.0.1 aaa 127.0.0.1
Having tested that solution, I noticed your update with examples. For IPv4, all of the octets should be in the range 0-255. I suspect you generated quick-and-dirty examples (by running along the number keys) which has produced invalid IP addresses. Changing 456 to 156 and 654 to 154, the same one-liner matches the way you want:
$ perl -MRegexp::Common=net -wnE '/^$RE{net}{IPv4}/ and next; /^\S+\s+ +.*?$RE{net}{IPv4}/ and say' ADMIN__SANDRO_DESK="123.156.78.90" # ilcylic Desktop # ADMIN__SANDRO_DESK="123.156.78.90" # ilcylic Desktop # ADMIN__SANDRO_DESK="123.156.78.90" # ilcylic Desktop # 06/06/15 SR Chgd SANDRO 121.123.154.99 # 06/06/15 SR Chgd SANDRO 121.123.154.99
— Ken
In reply to Re: Seeker of Regex Wisdom (strings which don't form specific patterns)
by kcott
in thread Seeker of Regex Wisdom (strings which don't form specific patterns)
by ilcylic
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |