in reply to Matching a pattern in Regex
Can anyone tell me what's wrong in my code?The line
should use the $fno variable, as in$_ =~ s/<figr n="(.+?)">(.*?)<\/figr>/<FIGIND NUM="$fno" ID="FG.$figno +">$2<\/FIGIND>/g;
That will correct the repeated substitutions for the wrong number. After that, change the "if" to a "while" and the code works.$_ =~ s/<figr n="($fno)">(.*?)<\/figr>/<FIGIND NUM="$fno" ID="FG.$f +igno">$2<\/FIGIND>/g;
Works is good, but there are better ways. For those, see previous posts.
|
|---|