in reply to Regex exact pattern match problem!
Note also that Perl goes out of its way to make sure that you can do lots of things that seem like they must be multi-step in a single statement. Thus, as moritz implicitly observed, it's probably better to write $tmpFound = length($1) (well, and use a better name) than $tmpFound = $1; $tmpFound = length($tmpFound).
UPDATE: On testing, moritz's version does the same thing. I think that you want something like
my $translated; while ( $toTranslate =~ /(.*?)((?:3{4})*)/g ) { $translated .= $1; $translated .= '[' . length($2) . ']' if $2; }
UPDATE 2: eye and AnomalousMonk pointed out a better, s///g-based solution: just omit the while.
|
|---|