I want to find all regex matches within a string. The problem is that sometimes parts of one match are parts of another and I think this is throwing things off.
Example:
$test = "xTx\nxxTxxT";
$rx = 'x...T';
@matches = $test =~ /$rx/sg;
printf "match #%i:\n%s\n",++$i,$_ for @matches;
The code above finds only 1 match when there are actually 2 matches within the string. Perl grabs the first match "x\nxxT" and then I think it starts looking for a new match where that last one ended. What I'd like to do is also get the other match - "xTxxT".
Is there any way to get Perl to check the entire string for each greedy regex pass excluding any previously found patterns?