What kind of formal languages can modern regex engines parse?

后端 未结 3 771
野趣味
野趣味 2020-12-01 03:55

Here on SO people sometimes say something like \"you cannot parse X with regular expressions, because X is not a regular language\". From my understanding however, modern re

3条回答
  •  旧时难觅i
    2020-12-01 04:31

    You can read about regexes in An Introduction to Language And Linguistics By Ralph W. Fasold, Jeff Connor-Linton P.477

    Chomsky Hierarchy:

    Type0 >= Type1 >= Type2 >= Type3

    Computational Linguistics mainly features Type 2 & 3 Grammars

    Type 3 grammars:

    –Include regular expressions and finite state automata (aka, finite state machines)

    –The focal point of the rest of this talk

    Type 2 grammars:

    –Commonly used for natural language parsers

    –Used to model syntactic structure in many linguistic theories (often supplemented by other mechanisms)

    –We will play a key roll in the next talk on parsing.


    most XMLs like Microsoft DGML (Directed Graph Markup Language) that has inter-relational links are samples that Regex are useless.


    and this three answers may be useful:

    1 - does-lookaround-affect-which-languages-can-be-matched-by-regular-expressions

    2 - regular-expressions-arent

    3 - where-do-most-regex-implementations-fall-on-the-complexity-scale

提交回复
热议问题