Forums Register Login

req Exp

+Pie Number of slices to send: Send
Trying to use "xml1.replaceAll("<![CDATA[","");" but it throws

java.util.regex.PatternSyntaxException:

Wondering how to do the replacement.

The following did not work

xml1.replaceAll("<!/[CDATA/[","");
xml1.replaceAll("<!//[CDATA//[","");
Thanks in advance
Jaan
+Pie Number of slices to send: Send
You need to use backslashes (\\) not forward slashes (//) to escape things.
+Pie Number of slices to send: Send
If you are trying to escape characters in your regex because they have meaning in regexes, then you're doing it wrong. The regex escape character is backslash ("\") and not slash ("/"). Remember also that backslashes have to be escaped for Java as well, so you'll need pairs of backslashes.

Also I think that what you are doing has the possibility of converting well-formed XML to non-well-formed XML, but that's another topic.
+Pie Number of slices to send: Send
Wondering why it will make an xml a non well defined?
Thanks
Jaan
The overall mission is to change the world. When you've done that, then you can read this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 527 times.
Similar Threads
Appending XMLs
How can I include dynamic data inside XML?
Modifying XML
String String String
CDATA inside CDATA
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 04:24:41.