Index: /veekun/trunk/lib/Vee/BBCode.pm
===================================================================
--- /veekun/trunk/lib/Vee/BBCode.pm (revision 401)
+++ /veekun/trunk/lib/Vee/BBCode.pm (revision 402)
@@ -32,5 +32,4 @@
 # BUGS:
 #  - replace won't work with no_close
-#  - replace won't work when nested
 our %tags = (
     b       => { param => 0, start => '<strong class="bbcode-b">', end => '</strong>' },
@@ -85,6 +84,9 @@
     for my $tag (keys %tags) {
         if (exists $tags{$tag}{replace}) {
-            $input =~ s: (.*) \[ $tag \] (.+?) \[ / $tag \] : $1 . $tags{$tag}{replace}->(undef, $2) :gexis;
-            $input =~ s: (.*) \[ $tag = (.+?) \] (.+?) \[ / $tag \] : $1 . $tags{$tag}{replace}->($2, $3) :gexis;
+            while ($input =~ / \[ $tag ( = .+? )? \] /sx) {
+                # .* at the beginning ensures we catch innermost nestings first
+                $input =~ s: (.*) \[ $tag \] (.+?) \[ / $tag \] : $1 . $tags{$tag}{replace}->(undef, $2) :gexis;
+                $input =~ s: (.*) \[ $tag = (.+?) \] (.+?) \[ / $tag \] : $1 . $tags{$tag}{replace}->($2, $3) :gexis;
+            }
         } else {
             $input =~ s: \[ $tag \] : $tags{$tag}{start}->() :gexi;
