• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Removing special characters from a String

 
Greenhorn
Posts: 18
MySQL Database Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everyone,
I am reading a string from a JTextArea which contains special characters such as " and , and \etc. I want to assign this data to a string but it is generating exception for these special characters.
I know that we can assign these special characters to a string by using a backslash(\) before the special symbol. The problem is the data in the JTextArea is not entered by anyone but it is generated from somewhere else.
So, how can I assign this JTextArea data to the string and then replace these special characters later with a whitespace.
Thank you very much in advance
 
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

[ July 24, 2008: Message edited by: Piet Verdriet ]
 
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not quite, Piet. But I'm wondering why the string contains backslashes in the first place. For instance, if the character following the backslash is 'n', maybe the two characters are meant to be interpreted as an escape sequence, and you should replace them both with a linefeed. But if you really just want to get rid of those characters, shouldn't you replace them with an empty string instead of a space?
 
Piet Verdriet
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Alan Moore:
Not quite, Piet.



But, of course uncle_al..., err, I mean Alan! Silly me!

...
But I'm wondering why the string contains backslashes in the first place. For instance, if the character following the backslash is 'n', maybe the two characters are meant to be interpreted as an escape sequence, and you should replace them both with a linefeed. But if you really just want to get rid of those characters, shouldn't you replace them with an empty string instead of a space?[/qb]



My thoughts exactly. But it appears the OP has left the virtual building.

Regards,

Piet (aka prometheuzz)
[ July 25, 2008: Message edited by: Piet Verdriet ]
 
Alan Moore
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Piet Verdriet:
Piet (aka prometheuzz)


I thought there was something familiar about you. Then again, maybe it was just that scorched-ego smell that always lingers around people who've been participating in the Sun forums.
 
Manish Dhasmana
Greenhorn
Posts: 18
MySQL Database Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you please send me code snippet to do this, I tried to replace it with a space but can't!! Hoping for a final solution. Post the solution considering the following string for input..

Specify first corner point or [Chamfer/Elevation/Fillet/Thickness/Width]:
Specify other corner point or [Dimensions]:
Command: Specify opposite corner:
Command: li
LIST 1 found

LWPOLYLINE Layer: "0"
Space: Model space
Handle = 89
Closed
Constant width 0.0000
area 17.1232
perimeter 18.5024

at point X= 11.4358 Y= 22.2415 Z= 0.0000
at point X= 18.1285 Y= 22.2415 Z= 0.0000
at point X= 18.1285 Y= 19.6830 Z= 0.0000
at point X= 11.4358 Y= 19.6830 Z= 0.0000
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How did you try? Show us your code. People here will not solve the problem for you, but we'll help you solve it yourself.
 
reply
    Bookmark Topic Watch Topic
  • New Topic