Java Replace Regex not working

前端 未结 1 1297
不思量自难忘°
不思量自难忘° 2020-11-29 12:59

Why doesn\'t this line of code work? It\'s supposed to replace all the punctuations with nothing.

m = m.replace(\"[\\\\?\\\\.;:\'\\\"]\", \"\")
相关标签:
1条回答
  • 2020-11-29 13:35

    This is because replace takes a String; you need to call replaceAll, which does take a regular expression.

    0 讨论(0)
提交回复
热议问题