Forum Stats

  • 3,757,514 Users
  • 2,251,240 Discussions
  • 7,869,850 Comments

Discussions

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

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?

Tagged: