> > This may be a bug. I do a lot of replace() in my own code, with
> > sometime more than a megabyte of text and never ran into
> this problem.
> > Perhaps Michael Kay can shed some light on this one.
I haven't run into the problem. I wouldn't regard it as a bug if there is a
value N such that Java runs out of memory when doing a replace() on a string
of length > N, and I wouldn't regard it as surprising if N is greater in JDK
1.5 than in 1.4.
A practical workaround here would be to substring() the first 1000
characters, do the replace() on that, and then concat() the rest of the text
to restore the full string; if you want to be more scientific you could use
substring-before() whatever it is that appears at the end of the DOCTYPE.