veera has asked for the wisdom of the Perl Monks concerning the following question:
I am searching a file for this pattern(Figure <xref ref-type="fig" rid="F1">1</xref>)and need to be replaced as (\protect\customizeref{F1}{Figures}{}) it replaces first match in a line. i used /g operator in regular expression. but no difference.
for($il=0;$il<$isize;$il++) { $input[$il] =~ s/<xref ref-type="fig" rid=/\\protect\\customizeref +{/g; if($input[$il] =~ /\\protect\\customizeref{(.*?)<\/xref>/) { # $input[$il] =~ /<xref ref-type="fig" rid="(.*?)<\/xref>/; print ("$1\n"); $_ = $1; $same = $1; $dx1 = /"(.*)"/; $dx1= $1; $dx2 = />(.*)/; $dx2= $1; print ("$dx1\n"); print ("$dx2\n"); $input[$il] =~ s/\\protect\\customizeref{$same<\/xref>/\\prote +ct\\customizeref{$dx1}{Figures}{}/g; $input[$il] =~ s/$same/$dx1}{Figures}{}/g; } if((defined $same) and (defined $dx1)) { print(">$same\n"); $input[$il] =~ s/$same<\/xref>/$dx1}{Figures}{}/g; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Multi replace in a Line
by hdb (Monsignor) on Jun 20, 2013 at 09:49 UTC | |
by veera (Initiate) on Jun 20, 2013 at 10:57 UTC | |
|
Re: Multi replace in a Line
by gurpreetsingh13 (Scribe) on Jun 20, 2013 at 10:33 UTC | |
by veera (Initiate) on Jun 20, 2013 at 10:54 UTC | |
by gurpreetsingh13 (Scribe) on Jun 20, 2013 at 11:02 UTC |