‎2020 May 08 12:11 AM
Hi experts,
I need a regex to use on Replace statement, that clear all xXmlCTe tags on a string.
Originally, string don't have line breaks or spaces between tags.
<xXMLCTe xmlns:ns0="http://www.teste1.com">
<xXMLCTe xmlns="http://www.teste2.com">
<cteProc versao="3.00">....</cteProc>
</xXMLCTe>
</xXMLCTe>
After replace...
<cteProc versao="3.00">....</cteProc>
If syntax is different on java and ABAP, I would appreciate if you could send me both.
Thanks a lot!
‎2020 May 08 5:39 AM
Something like this regular expression? (run program DEMO_REGEX_TOY)
</?xXMLCTe[^>]*>? = previous character is optional
[^...] any character which is not one of the characters inside
* repeat previous element zero or any number of times
‎2020 May 08 5:39 AM
Something like this regular expression? (run program DEMO_REGEX_TOY)
</?xXMLCTe[^>]*>? = previous character is optional
[^...] any character which is not one of the characters inside
* repeat previous element zero or any number of times
‎2020 May 08 6:42 AM
Since he is going to replace the tags, can we only focus on the starting part of the tag with the below regular expression:
<\/?xXMLCTeIt works very similar to what Sandra has mentioned, it will select only the tag name so it might come in handy if you want to keep the attributes.
You can play around in https://regexr.com/ it is really helpful for regex.
‎2020 May 08 10:36 AM
Hi, Miguel,
I would like to note that generally there are tools for XML processing in ABAP, so there is no need to reimplement XML parser/builder. Regexp might be ok for this minor task, but should you have something more complex later - I would recommend to have a look at those tools.
‎2020 May 08 2:28 PM
Thanks for all!
Sandra, your regular expression is exactly what I need.
Accept button is not available for me.
Best regards!
‎2020 May 08 2:57 PM
I hope you have now one step in regular expressions and can learn more powerful ones by reading the documentation.