in reply to using $1 as find string
This code might work fine for what you're doing, but please keep in mind that regular expressions are not very good at doing these kind of substitutions on nested data. For example, if you try the following:
$_ = "<it>a</it>+2<it>b</it>" . "<sup><it>cd<sup><it>foo</it></sup></it></sup>\n"; s!</it><(.*?)><it>(.*?)</it></\1>!<$1>$2</$1></it>!g; print;
You'll see that it does not quite do what you expect. To make something that handles data like this, you would have to build a more complex parser (or use one of the ones available -- HTML::TokeParser, HTML::TreeBuilder, etc).
|
|---|