Regex to use each letter only once?

后端 未结 1 1058
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-19 13:24

Is it possible to construct a PCRE-style regular expression that will only match each letter in a list only once?

For example, if you have the letters \"lrsa\" and y

相关标签:
1条回答
  • 2020-12-19 14:04

    You can use negative look-ahead:

    ^(?!.*?(.).*?\1)[lrsa]*m[lrsa]*$
    

    will do what you want

    0 讨论(0)
提交回复
热议问题