开发者

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

开发者 https://www.devze.com 2023-04-08 02:01 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: How do I replace a character in a string in Java?
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

精彩评论

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

关注公众号