Is “regex” in modern programming languages really “context sensitive grammar”?

前端 未结 3 1607
死守一世寂寞
死守一世寂寞 2020-12-16 19:39

Over the years, \"regex\" pattern matching has been getting more and more powerful to the point where I wonder: is it really just context-sensitive-grammar matching? Is it a

3条回答
  •  Happy的楠姐
    2020-12-16 20:10

    There are features in modern regular expression implementations that break the rules of the classic regular expression definition.

    For example Microsoft’s .NET Balancing Group (? … ):

    ^(?:0(?)|1(?<-L>))*(?(L)(?!))$
    

    This does match the language L₀₁ = {ε, 01, 0011, 000111, … }. But this language is not regular according to the Pumping Lemma.

提交回复
热议问题