in reply to Regex for ignoring paths

As always with regexes, a single example is not really enough. For example, are the strings you're looking for always in parentheses? Is it really safe to assume that you don't want any matches that come after a slash? And so on. See Re: How to ask better questions using Test::More and sample data.

Anyway, a negative lookbehind could work, as long as you set the conditions right: (?<![\/\w])(\w+\.\w+) (live demo)

Replies are listed 'Best First'.
Re^2: Regex for ignoring paths
by Amblikai (Scribe) on Oct 31, 2018 at 13:34 UTC

    Yeah i guess i really over-simplified it with the example

    My workaround was to look for only occurrences where the regex was in parentheses, which was fine.

    However i couldn't guarantee that they would only ever occur in parentheses, whereas i could guarantee that i never wanted a match with a preceding backslash, so that seemed like the elegant approach which to me is better practice.

    Anyway, long story short, you answered my question! I can't believe i missed having the first part of the regex in the negative look behind. Seems so simple now!

    Thanks for your help!