I try to understand behavior of Regex101 debugger, This is the regex link, So if you activate the debugger and take a look from line 45, You can see the following behavior:
- Line 45 the engine is watching the $ sign and understand that the end of the string haven't reached yet, So it need to subtract the string.
- My problem is with lines (46,48,50,52,54), I try to understand why the engine is go from the $ sign (line 45) inside the subpattern(line 46) when the actual subtraction is done when the engine is on the $ sign, The way i see it is that 46,48,50,52,54 are wasted lines i can't understand their contribution, I mean why should i go inside the subpattern when the change happen when the engine on the $ sign to check if the string was end.
If anyone can help me with that i will be very thankful.
Update:
The regex:
<\/span>((?:(?!<\/span>)[\s\S])+)$
The string:
string</span>string</span>string</span>theStringIWant