`regex{n,}?` == `regex{n}`?

后端 未结 7 1856
灰色年华
灰色年华 2021-01-20 15:06

-edit- NOTE the ? at the end of .{2,}?

I found out you can write

.{2,}?

Isnt that exactly the same as bel

7条回答
  •  天涯浪人
    2021-01-20 15:38

    In isolation they probably behave identical but not inside larger expressions because the lazy version is allowed to match more than two symbols.

                 abx        abcx
    
    ^.{2,}?x$    match      match
    ^.{2}x$      match      no match
    

提交回复
热议问题