Yes, Polyglot, that's what I want. Could you please elaborate on your suggestion. How do I perform the non-global substitutions for their corresponding positions? It is possible that exactly the same pattern may get repeated in a sentence, so their positions need to be taken into account, possibly using substr function. Still, I cannot figure out how that works. I tried to do something like this but it does not work.
$string=$line="Input sentence";
if ($line =~ /\*\*([^\*]+)\*\*\s(kinase|isoform|protein|peptide|li
+gand)\s\$\$([^\$]+)\$\$\s[\(\,]\s\*\*([^\*]+)\*\*\s[\)\,]/) {
print "yes";
while ($line =~ /(\*\*([^\*]+)\*\*\s(kinase|isoform|protein|pe
+ptide|ligand)\s\$\$([^\$]+)\$\$\s[\(\,]\s\*\*([^\*]+)\*\*\s[\)\,])/g)
+ {
$pattern=$1;
$string =~ s/(\*\*([^\*]+)\*\*\s(kinase|isoform|protein|pe
+ptide|ligand)\s\$\$([^\$]+)\$\$\s[\(\,]\s\*\*([^\*]+)\*\*\s[\)\,])/pq
+rstuv/;
$string =~ s/\*\*//g; $string =~ s/\$\$//g; $string =~ s/p
+qrstuv/$pattern/;
print WF "$string\n";
$string=$line;
}
}
| [reply] [d/l] |