in reply to Re^2: Regex, capturing variables vs. speed
in thread Regex, capturing variables vs. speed
The regex engine is not seeing any $1. A $1 in a regex does not mean anything special, it’s just a variable that gets interpolated as a literal string. In your case, $1 is empty when that pattern is compiled, so /(.?lah)$1{2}/ becomes simply /(.?lah){2}/. You can see this if you read the compiler output carefully – the CURLYX[0] {2,2} applies to the parenthesised expression.
Makeshifts last the longest.
|
|---|