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. ie
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
根据您的解释,您不需要.*
:
foo\s\d+(?!</end>)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.