in reply to find and replace
$a = "<exp>2a+α-b2+bβ2</exp><br>"; $a =~ s#(<exp>)(.*?)(<\/exp>)#$1.&expr($2).$3#egsi; print $a; sub expr { my($a) = @_; $a =~ s#([A-Z])#<it>$1</it>#gsi; $a =~ s#(\&)(.*?)(\;)#$1.&tmp($2).$3#egsi; sub tmp { my($tmp) = @_; $tmp =~ s#(<it>|<\/it>)##gsi; return $tmp; } return $a; }
o/p : <exp>2<it>a</it>+α-<it>b</it>2+<it>b</it>β2</exp>
Gubendran.L
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: find and replace
by texuser74 (Monk) on Dec 29, 2004 at 01:34 UTC |