From: Arne Vajhøj on
On 04-05-2010 08:44, gwoodhouse(a)gmail.com wrote:
> Quick one:
>
> I'm trying to remove this from a String: "<![CDATA["
>
> But when using this line it ignores it (Would usually just single
> escape it but java doesn't like that either):
> tagContents.replaceAll("<!\\[CDATA\\[", "");
>
> When using this one it throws an execption (With good cause since [ is
> a regex special character):
> tagContents.replaceAll("<![CDATA[", "");
>
> Whats your guys suggestion?

Besides the already stated about using return value and literal,
then I will say that you should consider using one of Java's many
XML libraries instead of using regex to manipulate XML with.

Arne
From: bugbear on
Arne Vajh�j wrote:
> On 04-05-2010 08:44, gwoodhouse(a)gmail.com wrote:

> Besides the already stated about using return value and literal,
> then I will say that you should consider using one of Java's many
> XML libraries instead of using regex to manipulate XML with.

Agreed. It's sad that XML, the touted "simple" replacement/successor
to SGML became so complicated that a library (and a large one!) is
needed, but it is.

BugBear
From: RedGrittyBrick on
On 05/05/2010 09:03, bugbear wrote:
> Arne Vajhøj wrote:
>> you should consider using one of Java's many XML libraries instead
>> of using regex to manipulate XML with.
>
> Agreed. It's sad that XML, the touted "simple" replacement/successor
> to SGML became so complicated that a library (and a large one!) is
> needed, but it is.

Amen.

Actually several large libraries. Choosing between them is a problem in
itself, at least for newbies.

--
RGB
Stalled in the trough of XML disillusionment.
http://en.wikipedia.org/wiki/Hype_cycle
From: Lew on
bugbear wrote:
> Agreed. It's sad that XML, the touted "simple" replacement/successor
> to SGML became so complicated that a library (and a large one!) is
> needed, but it is.

You say that as if you found something wrong with it.

--
Lew
From: Mike Amling on
bugbear wrote:
> Arne Vajh�j wrote:
>> On 04-05-2010 08:44, gwoodhouse(a)gmail.com wrote:
>
>> Besides the already stated about using return value and literal,
>> then I will say that you should consider using one of Java's many
>> XML libraries instead of using regex to manipulate XML with.
>
> Agreed. It's sad that XML, the touted "simple" replacement/successor
> to SGML became so complicated that a library (and a large one!) is
> needed, but it is.

Yep. That's why I wrote my own implementations of an XML parser,
formatter and validator (DSD), years ago. I got tired of shipping two
giant jar files that served no other purpose. It was worth the effort
just to get the ability to use DSD validation rather than XML Schema.
Note: I'm not advocating this for everybody. But it sure works for me
(and my colleagues).
I expect this post may generate some controversy.

--Mike Amling