Regular expression for no more than two repeated letters/digits

前端 未结 5 1702
北恋
北恋 2020-12-03 07:23

I have a requirement to handle a regular expression for no more than two of the same letters/digits in an XSL file.

  • no space
  • does not support special
5条回答
  •  一生所求
    2020-12-03 07:57

    For matching the same character repeated 3 or more times consecutively, try:

    ([a-zA-Z0-9])\1{2,}
    

    Sample matches (tested both here and here): AABBAA (no matches), AABBBAAA (matches BBB and AAA), ABABABABABABABA (no matches), ABCCCCCCCCCC (matches CCCCCCCCCC).

提交回复
热议问题