Which regular expression requires backtracking?

后端 未结 2 1401
时光取名叫无心
时光取名叫无心 2021-01-24 13:08

There are three different solutions to implement regular expression matching: DFA, NFA and Backtracking. I am looking for examples:

  • a regexp, which can be solved w
2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-24 13:31

    i guess there is more than 1 meaning to the word backtracking - even '.*a' has to backtrack to match the string "lalaiiiiiii" (because .* will first match the whole string - so then a won't match anything - and only then it will give up one character at a time, so the final match would be "lala")

    i highly recommend http://www.regular-expressions.info/

提交回复
热议问题