Try this in your cycl:

 foreach $x (keys %Replacements)
 {
 eval("\$inputstr =~ s/$x/$Replacements{$x}/g");
 }

Or somthing like this; feature to remember:
$inputstr should not extends; we do this by \$inputstr but other variables
shoul go.


----- Original Message -----
From: "Girish (Skyscape)" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, October 25, 2001 11:42 AM
Subject: Regex query


> Hi All,
>
> Can this be done ?
>
> sample string
> E=mc;s2
>
> should get converted to
> E=mc<sup>2</sup>
>
> similarly H;b2O should get converted to H<sub>2</sub>O
>
> for this I use following code
>
> %Replacements = (
> ";s(\d)", "<sup>$1</sup>"
> ,";b(\d)", "<sub>$1</sub>"
> );
>
> $inputstr = "E=mc;s2";
> foreach $x (keys %Replacements)
> {
> $inputstr =~ s/$x/$Replacements{$x}/g;
> }
> print "\n$inputstr";
>
> I get output as E=mc;s2
> Where am I going wrong ?
>
> Thanks in advance,
>
> Girish
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to