# Extracting regex submatch boundaries without backtracking

I'm attempting to develop from scratch a simple regex engine. I would like for my engine to have the ability to report, "The regex matched on a substring of this line starting at index and ending at index ."

It makes sense to me how to accomplish this using recursive backtracking. However, I'd like my implementation of the search to use Thompson's multi-state approach. Is this feasible?

• Isn't the grep utility already doing that ? – m.raynal Aug 28 at 20:07
• You mean using the multi-state approach? – Daniel Walker Aug 28 at 20:29

typedef struct stateRecord {