Regular expression to match string without repeated characters

后端 未结 2 1257
无人及你
无人及你 2021-01-22 11:49

I\'m looking for a simple regular expression to match the string where no repeated characters. Example:

  • JHMCU26809C211501 - good
2条回答
  •  长发绾君心
    2021-01-22 12:45

    If its a duplicate 3 or more times in a row, this is the fastest
    way to do it. (no phony demo provided)

    ^(?:(.)(?!\1{2}))+$

     ^ 
     (?:
          ( . )                         # (1)
          (?! \1{2} )
     )+
     $
    

提交回复
热议问题