Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Eliminating Unicode Characters and Escape Characters from String

  1. #1
    Junior Member
    Join Date
    Dec 2013
    Posts
    5
    My Mood
    Bored
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Eliminating Unicode Characters and Escape Characters from String

    I want to remove All Unicode Characters and Escape Characters like (\n, \t) etc. In short I want just alphanumeric string.
    for example :

    \u2029My Actual String\u2029
    \nMy Actual String\n

    I want to fetch just 'My Actual String'. Is there any way to do so either by using any string built in method or Regular Expression ?

    Thanks in Advance


  2. #2
    Member andbin's Avatar
    Join Date
    Dec 2013
    Location
    Italy
    Posts
    443
    Thanks
    4
    Thanked 122 Times in 114 Posts

    Default Re: Eliminating Unicode Characters and Escape Characters from String

    Quote Originally Posted by bilalonjavaforum View Post
    I want to remove All Unicode Characters and Escape Characters like (\n, \t) etc. In short I want just alphanumeric string.
    for example :

    \u2029My Actual String\u2029
    \nMy Actual String\n

    I want to fetch just 'My Actual String'. Is there any way to do so either by using any string built in method or Regular Expression ?
    First, you should clarify where are these strings. Do you have a file (or any other character source) that contains literally '\' followed by 'u' followed by '2' etc... ? Or do you have a literal string in a Java source file like:

    String s = "\u2029My Actual String\u2029";

    In this last case, at runtime you don't have an "escape". The first and last chars are a single character with code 0x2029 (8233 in decimal). The "escape" is only in the source file!

    So please, clarify.
    Andrea, www.andbin.netSCJP 5 (91%) – SCWCD 5 (94%)

    Useful links for Java beginnersMy new project Java Examples on Google Code

  3. #3
    Junior Member
    Join Date
    Dec 2013
    Posts
    5
    My Mood
    Bored
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Eliminating Unicode Characters and Escape Characters from String

    I am reading this string from file. And after reading from file '\' is replaced by '\\' thats why it is not replacing it.

Similar Threads

  1. How to replace characters in Array with user input Characters
    By gdoggson in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 4th, 2013, 05:53 AM
  2. Replies: 2
    Last Post: March 28th, 2013, 09:54 AM
  3. Trying to display Unicode characters
    By kc120us in forum What's Wrong With My Code?
    Replies: 12
    Last Post: January 16th, 2012, 05:55 PM
  4. Strange problem printing Unicode characters
    By sophist42 in forum What's Wrong With My Code?
    Replies: 9
    Last Post: April 29th, 2011, 10:53 AM
  5. How to check whether the string contains only the specified characters ????
    By j_kathiresan in forum Java Theory & Questions
    Replies: 3
    Last Post: April 30th, 2010, 08:49 AM