0

I want to understand how regex parser work so i started debug a string using Regex buddy

also from http://www.regular-expressions.info/engine.html

Here author explains how Regex engine parser works using following regular expression

/cat/

and string

"He captured a catfish for his cat."

author said that if Regex engine didn't find a matching token it backtracks to the last matching character

when i debug this in Regex buddy see here it started backtracking at the very first position

Why is it so ??

Cody
  • 2,480
  • 5
  • 31
  • 62
  • The engine does not know where your match potentially starts, so it checks every single character from left to right as a potential start for the match. This is what the author describes in the first paragraph of section "The Regex-Directed Engine Always Returns the Leftmost Match" on the page you linked. – Martin Ender May 22 '13 at 09:47

1 Answers1

1

In RegexBuddy's debugger, the backtrack label signifies: "This token has failed to match; now I'm going to backtrack. The next step in the debugger shows what the regex engine actually backtracked to. In your screen shot there never is a next step after backtrack because the regex engine didn't have anything to backtrack to.

Jan Goyvaerts
  • 21,379
  • 7
  • 60
  • 72