I guess in it's most simplistic form, my question is whether the state that regex uses to determine whether $ was already matched is available to me?
For example:
my $str = "abc";
$str =~ m/.|$/g; # succeeds, and pos goes to 1
$str =~ m/.|$/g; # succeeds, and pos goes to 2
$str =~ m/.|$/g; # succeeds, and pos goes to 3
$str =~ m/.|$/g; # succeeds, and pos stays at 3 # Why does this behave
+ differently than the next regex? pos($str) is 3 for both calls
$str =~ m/.|$/g; # fails and resets pos
How does the engine know that it has already succeeded with the fourth regex (when pos is already 3)? There must be some mechanism that records that internally in the regex engine. I'd like to know if that information is accessible.
FYI, I rewrite my code constantly, this issue came up during one rewrite, I have to go back and see if there's a case where it is helpful. But the question still piqued my interest. I would like to understand if the internal structure that has this information ($ matched) is accessible |