The hard part is dealing with nested tags, but if you start with the inside tags and work outwards, you have no real problems.use strict; use warnings; my $str = ' <x <y >>'; my $c = 0; my @arr; while ($str =~ /<[^<>]+>/) { $str =~ s/<([^<>]+)>/`$c`/; $arr[$c++] = $1; } s/ /"/ig for @arr; while ($str =~ /`\d+`/) { $str =~ s/`(\d+)`/<$arr[$1]>/g; } print $str;
In reply to Re: Matching HTML Tags
by TedPride
in thread Matching HTML Tags
by pcadv
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |