I'm trying to create a regex that matches the five last "words" of the input, where a "word" is defined as anything that matches [^ ]+
or [^ ]*<[^>]*>[^ ]*
(so anything separated by spaces, but counting spaces between <
and >
as letters)
I tried this:
/([^ ]+(?:(?<!<[^>]+) +(?![^<]*>)(?:.*?)){0,4})$/
but it gives me the error that lookbehind must be fixed lenght.
Say I have the following string:
'It\'s just that he <span class="verb">appear</span>ed rather late.'
it should match
'that he <span class="verb">appear</span>ed rather late.'