Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Regex replaceAll question

807603Nov 30 2007 — edited Dec 1 2007
I am using replaceAll to replace a bunch of "tags" with content for this bit of software that I am porting (from something else) that creates documents (in the end) by populating templates with data.

Here's my problem. The "tags" are all okay (not giving any regex content) but some of the data is. Because at first now I hit data that as a String has some regex funky characters in it. And regex got all all whiny about that because there aren't any matching groups. Well no. That's true.

So I have to escape the $. But it occurs to me that I could well have more than this problem with other bits of content (including some parts I haven't gotten to yet) and I am wondering if there is any sort of easy solution. Is there way to tell replaceAll that the replacement String is a "literal" replacement i.e. I don't want any regex parsing at all just replace the found "tag" with the "content", that's it.

Some sort of escape the whole sequence? Possibly. But I don't understand what it would be. \ is just for as single character?

So any quick solution? Or alternative?

BTW I am stuck with 1.4 on this project.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 29 2007
Added on Nov 30 2007
21 comments
202 views