Regex in between lines

Hey,

Can someone help me with a regex to get the text in between “PaymentHistory” and “/PaymentHistory”

I need all text in between that. Fully understand I could use xml to do it but would prefer RegEx. Reason is getting the text in xml format is a bunch more steps. Let me know!

“-PaymentHistory”

“ln literal=“y” No complaints/ln”

"ln literal=“y"Nothing./ln”

“/PaymentHistory”

Had to add in “” to make the text appear “” is actually meant to be < and >

Hi Asanka,

Use below regex

str_Result = System.Text.RegularExpressions.Regex.Match(str_input.tostring,"(?<=PaymentHistory).*(?=/PaymentHistory))")

Hope it will work. Let me know in case of issue

Tried it in the regex tester and no luck! I think it has to do with the data being on different lines

you input string is on same line?

@Asanka
have a look here:
grafik

as .* not matching line breaks
grafik

we just include \n and \r - last for beeing prepared for the windows world

Pattern:
(?<=<PaymentHistory>)(.|\r|\n)*?(?=</PaymentHistory>)

not working for me:

@Asanka
done with https://regex101.com/

Also working in regexstorm http://regexstorm.net/tester
grafik

in your case just enable the multiline flag. However as it should run within uipath, do quick test there

1 Like

BOOM! It worked. Thanks so much!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.