remove substring in a string without using regex (cannot use replaceAll)

前端 未结 5 1624
深忆病人
深忆病人 2021-01-28 04:32

I need to remove some substrings in strings (in a large dataset). The substrings often contain special characters, like these: ., ^, /,... and replaceAll() would treat them as s

5条回答
  •  时光说笑
    2021-01-28 05:18

    Just use String.replace(). It functions the same way, but it deals with escaping the special characters internally to avoid you having to worry about regex.

    Documentation

提交回复
热议问题