Reputation: 399
Hello I have a string like a= " $ 2 187.00"
. I tried removing all the white spaces and the bad characters like a.replaceAll("\\s","").replace("$","")
. but i am getting error
Impossible to parse JSON response: SyntaxError: JSON.parse: bad escaped character
how to remove the bad character in this expression so that the value becomes 2187.00.Kindly help me .Thanks in advance
Upvotes: 1
Views: 516
Reputation: 9868
def a = ' $ 2 187.00'
a.replaceAll(/\s/,"").replaceAll(/\$/,"")
// or simply
a.replaceAll(/[\s\$]/,"")
It should return 2187.00
.
Note
$
has special meaning in double quoted strings literals ""
, called as GString
. Upvotes: 4