Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2017
    Rep Power

    Default 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:


    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.

    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?

  2. #2
    Sierra is offline AN21XX
    Join Date
    Mar 2012
    Rep Power

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

    In Java Strings are UTF-8 - also the regex I think. Are you sure that you have problem with the above string if you read it in correctly?

    Maybe you can check out encoding the string to HTML using the Apache Common library or similar. Check this out:
    I like likes!

Similar Threads

  1. Replies: 2
    Last Post: 01-26-2014, 04:41 PM
  2. Split a string, can't escape '\'
    By skania in forum New To Java
    Replies: 2
    Last Post: 06-18-2013, 09:40 PM
  3. Replies: 3
    Last Post: 02-04-2013, 08:25 AM
  4. Make String into chars
    By myst in forum New To Java
    Replies: 19
    Last Post: 06-20-2010, 05:24 PM
  5. make a variable name from a string?
    By Kinnikinnick in forum New To Java
    Replies: 3
    Last Post: 11-13-2007, 04:54 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts