Search code examples
regexpcre

REGEX if string is present then select the last character on the line


I am using PCRE.

I need help developing a REGEX to select the end of the last character at the line. In my example below I am using a snippet from an XML file and I need the regex to find any lines that have 'target=' if it does then to select '>'

<wrapping target="CLIENT" source="INCD"/>

I have tried the regex below but I am only getting CLIENT" source="INCD"/ I need it to find > if target= exisit.

(?<=target=")(.*?)(?=>)

Solution

  • I was able to achieve my goal with target=.+?".\K>