I want to match "foo 6" but not "foo 6</end>". At the moment I have the expression: foo\s\d+(?!.*</end>). The problem is that it will also discard foo 6 if there is an </end> tag way later on in the string. i.e.
foo 6 Matches – This is correct
foo 6</end> Does not match – This is correct
foo 6 word word word word number word number word</end> Does not match – This is incorrect as foo 6 should still match here.
The regex should allow for the 3 above scenarios to be correct
From your explanation you don’t need the
.*: