-1

I have string "the best, **i have". I want to replace ", **" to " ", my code

string str = "the best, **i have";
string a = str.replace(", \\**", " ");

but if string is "the best, she have money" then string replace to "the best she have money".

thanks!

1 Answers1

0

You are not escaping the second asterisk properly.

The regular expression that you give means ", " literally, followed by any number of "*" characters.

The correct regex string should be ", \\*\\*".

T Tse
  • 786
  • 7
  • 19