Removing repeated characters in String

后端 未结 4 1648
半阙折子戏
半阙折子戏 2020-12-20 04:49

I am having strings like this \"aaaabbbccccaaffffddcfggghhhh\" and i want to remove repeated characters get a string like this \"abcadcfgh\".

A simplistic implementati

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-20 05:44

    With regex, you can replace (.)\1+ with the replacement string $1.

提交回复
热议问题