This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Replace Question Mark Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Replace Question Mark " Watch "Replace Question Mark " New topic

Replace Question Mark

Ragupathirajan Venkatesan
Ranch Hand

Joined: Aug 18, 2010
Posts: 62
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.

Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902

Just skip the special meaning of ? using backslash '\'.

[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 38100
You may need to escape the backslash too, so try changing ? to \\?
James Sabre
Ranch Hand

Joined: Sep 07, 2004
Posts: 781

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.

Retired horse trader.
 Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
Ragupathirajan Venkatesan
Ranch Hand

Joined: Aug 18, 2010
Posts: 62
Dear All,
Thanks a lot. It works for me.
I agree. Here's the link:
subject: Replace Question Mark
Similar Threads
mock question
Illegal XML characters
Replace Special Character with CR and LF
Regarding remove word in a string
How to replace values in a string?