Bear with me on this as I might not be explaining this too well.
I have a simple regex:
^(The\s)?(cat\s)?(sat\s)?(on\s)?(the\s)?(mat\.)?
To which the text
The cat sat on the mat.
passes successfully. Hurrah!
However, what I'm after is a way to find out which groups the regex failed on. For example:
The cat sat on the mat # fails on group 6 (no period)
The cat sat on teh mat. # fails on group 5 (teh instead of the)
The kat sat on the mat. # fails on group 2 (kat instead of cat)
The latter example was otherwise fine except for that one group fail. My question is this: Is there a way in Python to determine if that string would have been otherwise successful on a group by group basis - without having to create iterations of the regex fir each group in part?