How do I remove some characters from my String

后端 未结 8 911
无人及你
无人及你 2020-12-17 17:03

i want to remove all of the following chars from my string

\">[],-\"

at the moment im doing this. but there must be a more effic

相关标签:
8条回答
  • 2020-12-17 18:01

    Using the replace / replaceAll methods causes a new Pattern to be compiled each time. So if you are doing this multiple times I would strongly suggest either looping through the characters or creating a single regular expression to use repeatedly.

    0 讨论(0)
  • 2020-12-17 18:01

    You could loop through each character, appending them one by one to a StringBuilder() unless they match one of the characters you are removing.

    But I'm not sure that'd be a whole lot faster.

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