Java: replace a set of characters with other different characters

后端 未结 4 1528
梦谈多话
梦谈多话 2021-01-23 09:22

I am supposed to make a custom decorator so I can replace both in an input from console and from a file:

  1. A set of chars with a specific character (e.g. char[
4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-23 10:00

    DjMike,

    For the second one, what would be helpful during the replacement is to call a method that you infuse with the logic to replace different characters with different strings.

    PHP has a great facility that does just this called preg_replace_callback(). The linked answer is to a question about the Java equivalent of preg_replace_callback()

提交回复
热议问题