Regex is behaving lazy, should be greedy

后端 未结 3 1759
感动是毒
感动是毒 2021-02-20 15:12

I thought that by default my Regex would exhibit the greedy behavior that I want, but it is not in the following code:

 Regex keywords = new Reg         


        
3条回答
  •  故里飘歌
    2021-02-20 15:53

    Laziness and greediness applies to quantifiers only (?, *, +, {min,max}). Alternations always match in order and try the first possible match.

提交回复
热议问题