Skip to Main Content

New to Java

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!

Java regex - escape special characters - like quotemeta

807601Jun 18 2008 — edited Jun 18 2008
Hi

Is there a method in Java that is equivalent to Perl's "quotemeta"?

Basically I get a String input from user, and will remove them from a particular file. The problem is, the String.replaceAll accepts only regex as argument, and hence I have to supress/escape all the special characters like "(", ")", "*" etc.! Thats why I am looking for a method which can do this. Is there any? Kindly help.

Thanks
Sri
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 16 2008
Added on Jun 18 2008
4 comments
1,094 views