Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Regex to catch IPV4 and IPV6 whenever ip appears withing brackets

by Anonymous Monk
on Jul 10, 2018 at 15:12 UTC ( #1218243=note: print w/replies, xml ) Need Help??


in reply to Regex to catch IPV4 and IPV6 whenever ip appears withing brackets

If you specifically want to catch IP-addresses in brackets, I would first look for bracketed strings that contain digits, e.g. /(\(.*?0-9.*?\))/g, specifying "non-greedy" so that you get the shortest possible string.and applying this pattern as often as necessary to each input line. For each captured string, apply a Regexp::Common pattern to search for IP-addresses, also applying the pattern multiple times per-string. The check for digits occurring within the brackets is to reduce the number of false-positives on the first match loop.
  • Comment on Re: Regex to catch IPV4 and IPV6 whenever ip appears withing brackets

Replies are listed 'Best First'.
Re^2: Regex to catch IPV4 and IPV6 whenever ip appears withing brackets
by Anonymous Monk on Jul 10, 2018 at 15:13 UTC
    If a group could contain an inner parenthesized group then you may wish to use greedy patterns instead.
      If this is an issue, I would prefer to use Regexp::Common::Balanced.
      Bill
Re^2: Regex to catch IPV4 and IPV6 whenever ip appears withing brackets
by Anonymous Monk on Jul 11, 2018 at 14:03 UTC

    This "sundial" guy has been here for how many years? and he still doesn't know that <tt>...</tt> is not the way to mark off code. Dumbshit.

      A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1218243]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (2)
As of 2019-04-19 04:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I am most likely to install a new module from CPAN if:
















    Results (106 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!