Do you know where your variables are? | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Well of course I agree with Discipulus, because I do love debuggex :) Here is something that you can try to understand what happens: You don't have to understand how the second line of the regex works, it just prints debug information on the current state of the regex :). Do note that I have changed your sample input so that there are two different "TGA" at a multiple of three position. In both case, (\w\w\w)+ is a loop that reads three characters at a time. The difference is that in the first case, each times it reads three characters it lets the last part of the regex test the string (check if it is followed by TGA), if the test failed, three new characters are read and the test is ran again. The (\w\w\w)* loop of the second regex though, keeps reading characters as long are there are three characters to read, and it only lets the last part of the regex be checked after it is done, if the test fails, it goes back (backtracks) one iteration, and tries again. The /g simply memories the position of the last successful match, and starts reading from there on the next attempt. In reply to Re: Understanding a portion on the Perlretut
by Eily
|
|