# ... my %taglist_complex = ( 'email' => "$2", 'url' => "$2", 'img' => "$2" ); my %taglist_simple = ( 'b' => '$1', 'i' => '$1', 'u' => '$1', 'url' => '$1', 'img' => '\'$1\'' ); # Process Complex Tags -> [url="http://www.foo.bar.com"]foobar[/url] while (my ($tag, $regex) = each %taglist_complex) { $post =~ s/\[\s*$tag\s*=\s*['"]?([\w\W][^\]]*?)['"]?\](.[^\[|\]]*?)\[\s*\/\s*$tag\s*\]/$regex/gi; } # Process Simple Tags -> [url]http://www.foo.bar.com[/url] while (my ($tag, $regex) = each %taglist_simple) { $post =~ s/\[\s*$tag\s*\](.[^\[|\]]*?)\[\s*\/\s*$tag\s*\]/$regex/gi; } #...