I have the following string:
<SEM>electric</SEM> cu <SEM>hello</SEM> rent <SEM>is<I>love</I>, <PARTITION />mind
I want to find the last ‘SEM’ start tag before the ‘PARTITION’ tag. not the SEM end tag but the start tag. The result should be:
<SEM>is <Im>love</Im>, <PARTITION />
I have tried this regular expression:
<SEM>[^<]*<PARTITION[ ]/>
but it only works if the final ‘SEM’ and ‘PARTITION’ tags do not have any other tag between them. Any ideas?
And here’s your goofy Regex!!!
What that says is ‘While ahead somewhere is a PARTITION tag… but while ahead is NOT another SEM tag… match a SEM tag.’
Enjoy!
Here’s that regex broken down: