PerfectGamesOnline.com
PerfectGamesOnline.com

Reputation: 1778

Use regular expression in Xcode to exclude phrased from find results

I need to find in project files all occurrences of <LIB> or <M> but only if there is no <TOLERATED>.

E.g. find all this:

// <M> a bit of code
// <LIB> rename with prefix

But don't show these:

// <M><TOLERATED> a bit of code
// <TOLERATED><LIB> rename with prefix

My tries: This gives you results with both <LIB> and <TOLERATED>: <LIB>(.*?)TOL Then I've tried to negate the <TOLERATED> with: <LIB>(.*?)(?!TOL) but that gives me back lines with both <LIB> and <TOLERATED>

I've tried many other ways to exclude the <TOLERATED> from the search results but none of them worked:

<LIB>(?!TOL\b)\b\w+
<LIB>(.*?)(?!TOL\b)\b\w+
<LIB>(.*?)(?<!TOLERATED)
<LIB>(.*?)+\b(?<!\bTOLERATED)

and many others.

What I've been looking at: RegExp in Xcode: exclude matches from result set?

Thanks for your help --Josef

Upvotes: 1

Views: 1242

Answers (1)

Tomalak
Tomalak

Reputation: 338228

^(?!.*?<TOLERATED>).*?<(?:LIB|M)>

Upvotes: 2

Related Questions