File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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: 2904

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: 46409
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
jQuery in Action, 3rd edition