Let's say I have the following block of text:
Hi, here
is some text.
This is some Hi here more
And some.
I would like to highlight items with multiple words, like this:
However, I only want it to highlight the first match -- in other words the word shouldn't have a match before it (the second some shouldn't show up). The only way I can think to do this is using a negative lookbehind, but I'm using python's regex which doesn't allow variable-length lookbehinds. How could this be done?
And yes, of course I can do something like the following:
>>> from collections import Counter;Counter('Hi, here\nis some text. \nThis is some Hi here more\nAnd some.'.split())
Counter({'some': 2, 'is': 2, 'here': 2, 'And': 1, 'This': 1, 'text.': 1, 'some.': 1, 'Hi': 1, 'Hi,': 1, 'more': 1})
But I'm curious if it's possible to do this with a regex.
