last-occurrence

Finding the last occurrence of a word

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>[^<]*<PARTI...

Getting last occurrence of a string using regular expressions

Hi everone! I need to parse an HTML file and i've got something like this: <TAG1> <TAG1> TEXT_TO_FIND KEY <TAG1> </TAG1> <TAG1> </TAG1> </TAG1> </TAG1> Taking into account that there are multiple levels of anidation. How can I get the text TEXT_TO_FIND? In plain english, what I ...

Capture the last occurrence of a tag

My text is of the form: <Story> <Sentence id="1"> some text </Sentence> <Sentence id="2"> some text </Sentence> <Sentence id="3"> some text </Sentence> My task is to insert a closing tag </Story> after the last </Sentence>. In the text, every </Sentence> is followed by 3 spaces. I tried capturing the last </Sentence> using...

Using regex to find any last occurrence of a word between two delimiters

Hi all, Suppose I have the following test string: Start_Get_Get_Get_Stop_Start_Get_Get_Stop_Start_Get_Stop where _ means any characters, eg: StartaGetbbGetcccGetddddStopeeeeeStart.... What I want to extract is any last occurrence of the Get word within Start and Stop delimiters. The result here would be the three bolded Get below. S...