开发者

replace all occurences of "\x0d" in a Java String [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate:

How do I replace a character in a string in Java?

how 开发者_如何学Gocan i replace all occurences of '\x0d' in a Java String??

  • I have tried myString.replaceAll("\x0d", "")... does not works

and all the answers below does not work have tried that already

OMG :)


Apologies for the crap guys.


I believe you want this:

String test = "\r".replace("\r", "princess");
System.out.println(test);  // princess

ASCII 13 is Carriage Return


Escape the backslash:

myString = myString.replace("\\x0d", "whateverYouWantToReplaceWith")

See it working on ideone.


You may consider trying String.replace.


Just a guess -- String.replace? There's a character version and a "character sequence" version.


myString.replaceAll("\\x0d","whateverYouWantToReplaceWith");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜