Hi all,

I've introduced a Regex_Search in my server action as a means of taking text of XML (Rather than being represented as an XML object, my API call returns a string of XML text, which I must parse through manually as the actions provided in the XML extension haven't yielded much success.) To get around this, I'm using Regex to go through the XML and find everything in between the <result> tags. 

The pattern I use is: 


See: https://regex101.com/r/fr7Tha/1

When I assign this as a variable then call it, I am given the error: 

parsing "(?<=\)(.*?)(?=\<\/result>)/gm" - Reference to undefined group name result.

Why does this cut out the <result> part of the pattern in the error? If this is a legitimate regex pattern, why isn't it being recognized? Any info helps.


Regex can be VERY finicky in terms of the pattern syntax. I tested your test string with a simpler pattern:

"<result>(.*?)</result>" and that works fine, so I suspect there's something about how you're constructing the pattern that's at issue here.

I'll play a bit more and see if I see anything obvious, but I think this probably is more of a RegEx issue than anything OutSystems-specific.

If I'm honest, I'd recommend spending some time troubleshooting why you weren't able to get the native XML approach working, as using RegEx on markup can be hair-pullingly painful at best.


Thanks for the suggestion but that also includes the result tags in with the content when using regex. I need to use the positive lookahead/lookbehind in order to tell it to essentially do what index does (don't know why I didn't just use that instead.) I did get the regex to work though, and it ended up being a slight mistake that I'm kicking myself for; removing the escapes after the equals so the pattern looks now works with this:


I guess the reason I gave up on the XML approach was that I wasn't able to come up with a good structure to convert the text to an xml object then back again to text to use in a variable. The best I could get with it was using the XmlDocument_Load action then calling XmlElement_GetInnerText but was getting errors with that. 

If you have any input into this I would look into doing it differently, but for now this works for what I need from it.



I fully understand your willingness to move on once you have a solution that works. Parsing XML markup, whether via deserialization, or using RegEx, has never been my favorite task. But it has to be done sometimes.

Glad you found a solution that works for you.