Determine regular expression's specificity

后端 未结 4 1529
傲寒
傲寒 2020-12-18 01:31

Given the following regular expressions:

 - alice@[a-z]+\\.[a-z]+
 - [a-z]+@[a-z]+\\.[a-z]+
 - .*

The string alice@myprovider.com

4条回答
  •  执念已碎
    2020-12-18 02:03

    My gut instinct says that not only is this a hard problem, both in terms of computational cost and implementation difficulty, but it may be unsolvable in any realistic fashion. Consider the two following regular expressions to accept the string alice@myprovider.com

        alice@[a-z]+\.[a-z]+ 
        [a-z]+@myprovider.com

    Which one of these is more specific?

提交回复
热议问题