I'm trying to find a regex to indicate lines which does not have a duplicate string.
Input:
hi hello hello hi
hello hi hello hi
text hello halo hi
hello hello hi
hello halo hi
hello hello hi
I want to highlight all lines which do contain the word hello but do NOT have another hello on the same line.
Expected Output:
Only line 3 and 5 must be highlighted.
I tried with this regex:
\(hello\)\(.*hello.*\)\@!
but it doesn't do what I want to do.
How can I highlight a pattern on a line (or the entire line) when there is no double pattern on the same line?
Try this :
^\(\(.*hello.*\)\{2,}\)\@!.*hello.*$
explanation
"Match a whole line not containing at least twice hello but containing hello"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With