2

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:

  1. 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.
  2. 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
4
  • I can't see that link with my outdated browser. Can you post the regex instead of people having to contend with an obstical. Commented Mar 5, 2014 at 19:50
  • I have seen several strange behaviours with regex101 debugger, I think that this debugger is buggy, It is better to test with regexbuddy. Commented Mar 5, 2014 at 20:34
  • Is there a free version for regexbuddy or similar software for free? Commented Mar 5, 2014 at 23:26
  • @CasimiretHippolyte: Whats wrong with my debugger? It does exactly what its supposed to. The lines mentioned by Aviel are lines where the engine is asserting positions for a continued match. The result you see on regex101 are 100% accurate. Commented May 9, 2014 at 9:59

1 Answer 1

1

Should work. Have you used the Raw regex at that web site?
There should be no options selected, ie: no multi-line or global or anything.

 #  Delimited:      /<\/span>((?:(?!<\/span>)[\s\S])+)$/
 #  Raw:             </span>((?:(?!</span>)[\s\S])+)$   

 </span>
 (
      (?:
           (?! </span> )
           [\s\S] 
      )+
 )
 $ 

Perl test case -

if ( "string</span>string</span>string</span>theStrngIWant" =~ /<\/span>((?:(?!<\/span>)[\s\S])+)$/)
{
    print "found: '$1'\n";
}

Output >>

found: 'theStrngIWant'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.