Using explicitly numbered repetition instead of question mark, star and plus

后端 未结 4 2135
谎友^
谎友^ 2020-11-21 11:00

I\'ve seen regex patterns that use explicitly numbered repetition instead of ?, * and +, i.e.:

Explicit            Sho         


        
4条回答
  •  走了就别回头了
    2020-11-21 11:55

    They're equivalent (and you'll find out if they're available by testing your context.)

    The problem I'd anticipate is when you may not be the only person ever needing to work with your code. Regexes are difficult enough for most people. Anytime someone uses an unusual syntax, the question arises: "Why didn't they do it the standard way? What were they thinking that I'm missing?"

提交回复
热议问题