in reply to "Not containing something" in substitution

You were really close to it. I just modified your code the following way:
$begin = '[xyz]'; $end = '[/xyz]'; $string = '[xyz]level 1.1 [xyz]level 2.1[/xyz] rest of 1.1 [/xyz]'; 1 while ($string =~ s@ \Q$begin\E ((?:(?!=\Q$end\E).)*) \Q$end\E @ "<table><tr><td>$1</td></tr></table>" @igex); print $string;
Not terribly efficient, but it appers to do what you want.
Cheers,
CombatSquirrel.
Entropy is the tendency of everything going to hell.