Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

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!

How can you escape a String in order to make it reg exp parseable?

Akash RajgureSep 9 2020

Use case: Say, that you are programatically generating a bunch of files for which you use as prefix the file's name, because you need a way to know which generated files relates to which source file (which you would do then with a reg exp), but, for example, on a wikipedia entry such as:

Terreur_(Révolution_française)

apparently the "(" and ")" and also the French characters é, ç, seem to be problematic while running a reg exp in java

Algorithm is working fine with all other cases. Java Training

There is a way to escape html mark up in urls. Is there a similar way to espace strings intended to be used for regular expressions in Java?

Comments

Post Details

Added on Sep 9 2020
0 comments
209 views