Reputation: 85
I'd like to find any occurrence of specific word which is not preceded by other specific word using IntelliJ IDEA's Find in path (ctrl+shift+f). For example I'd like to find "end" but not "front-end".
There is similar question: Regex - Find all matching words that that don't begin with a specific prefix but solutions from there doesn't work in IntelliJ IDEA.
Do you know any way how to do it in IntelliJ IDEA?
Upvotes: 1
Views: 850
Reputation: 626689
The problem here is with word delimiting approach. Usually, words consist of letters, digits or _
. In your example, -
is not a word char.
Since your words are whitespace separated you may use
(?<!\S)(?!front)\S*end(?!\S)
See the regex demo.
Details
(?<!\S)
- a whitespace or start of string should appear immediately to the left of the current location(?!front)
- no front
can appear immediately to the right of the current location\S*
- 0 or more chars other than whitespace end
- end
substring(?!\S)
- a whitespace or end of string should appear immediately to the right of the current location.Upvotes: 1