How do you remove repeated characters in a string

后端 未结 7 449
感情败类
感情败类 2020-12-09 11:44

I have a website which allows users to comment on photos. Of course, users leave comments like:

\'OMGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG

7条回答
  •  臣服心动
    2020-12-09 12:32

    Edit : awful suggestion, please don't read, I truly deserve my -1 :)

    I found here on technical nuggets something like what you're looking for.

    There's nothing to do except a very long regex, because I've never heard about a regex sign for repetition ...

    It's a total example, I won't paste it here but I think this will totally answer your question.

提交回复
热议问题