• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Replace Question Mark  RSS feed

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,

I need to parse one xml file. while doing so I need to replace the ? with empty string.


for example,



please help to solve the issue. thanks in advance.


 
Ranch Hand
Posts: 2908
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just skip the special meaning of ? using backslash '\'.
 
Marshal
Posts: 61774
193
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may need to escape the backslash too, so try changing ? to \\?
 
Ranch Hand
Posts: 781
Java Netbeans IDE Ubuntu
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it is simple as replacing each '?' with an empty string then there is no need for replaceAll(), just use


Edit : Thinking about this, it looks to me like the OP has parsed an XML file using the wrong character encoding and now need to get rid of the resulting '?' that are created when the encoder does not recognise some bytes as characters.
 
Ragupathirajan Venkatesan
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear All,
Thanks a lot. It works for me.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!