Regular Expression to match 3 or more Consecutive Sequential Characters and Consecutive Identical Characters

前端 未结 15 2236
北荒
北荒 2020-11-28 11:41

I need regular expressions to match the below cases.

  1. 3 or more consecutive sequential characters/numbers; e.g. 123, abc, 789, pqr, etc.
  2. 3 or more cons
15条回答
  •  粉色の甜心
    2020-11-28 12:22

    • 3 or more consecutive sequential characters/numbers; e.g. 123, abc, 789, pqr, etc.

      (?:(?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)){2,}\d|(?:a(?=b)|b(?=c)|c(?=d)|d(?=e)|e(?=f)|f(?=g)|g(?=h)|h(?=i)|i(?=j)|j(?=k)|k(?=l)|l(?=m)|m(?=n)|n(?=o)|o(?=p)|p(?=q)|q(?=r)|r(?=s)|s(?=t)|t(?=u)|u(?=v)|v(?=w)|w(?=x)|x(?=y)|y(?=z)){2,}[\p{Alpha}])
      

      https://regex101.com/r/5IragF/1

    • 3 or more consecutive identical characters/numbers; e.g. 111, aaa, bbb, 222, etc.

      ([\p{Alnum}])\1{2,}
      

      https://regex101.com/r/VEHoI9/1

提交回复
热议问题