sahil
sahil

Reputation: 265

Issue with %0A replace in android

how can i remove %0A from this string :- this is enter key code, which i need to remove from entire string. so how can i do this?

input:-

"NA%0A%0AJKhell this is test %0A"

Output:-

NAJKhell this is test

i have tried

  String input = "NA%0A%0AJKhell this is test %0A";
  String output =  input.replaceAll("%0A",""); 

but still not get the output.

Upvotes: 1

Views: 830

Answers (2)

shift66
shift66

Reputation: 11958

replaceAll method takes a regex as parameter. Try to escape percent sign \\% I think it will work

String input = "NA%0A%0AJKhell this is test %0A";
String output =  input.replaceAll("\\%0A",""); 

Upvotes: 2

teoREtik
teoREtik

Reputation: 7916

If you are trying to use Regex API, so it should look like this:

input.replace("%A$", ""); - It will remove matching at the end of the String (because of $)

If you want to remove all %A, then

input.replaceAll("%A", "");

Upvotes: 1

Related Questions