Why are there so many different regular expression dialects?

前端 未结 4 1767
陌清茗
陌清茗 2020-12-06 05:00

I\'m wondering why there have to be so many regular expression dialects. Why does it seem like so many languages, rather then reusing a tried and true dialect, seem bent on

4条回答
  •  长情又很酷
    2020-12-06 06:00

    I think a good part of this is the question of who would be responsible for setting and maintaining the standard syntax and ensuring compatibility accross differing environments?

    Also, if a regex must itself be parsed inside an interpreter/compiler with it's own unique rules regarding string manipulation than this can cause a need for doing things differently with regard to escapes and literals.

    A good strategy is to take time to understand how regex algorithms themselves function at a more abstract level, then implementing any particular syntax becomes much easier. Similar to how each programming language has it's own syntax for constructs like conditional statements and loops, but still accomplish the same abstract task.

提交回复
热议问题