.+(?<=\])(.+?)(?=\[\/).+ #### #!/usr/bin/perl -w use strict; my $bold = "[b]bold text[/b]"; my $red = "[color=Red]Red text text[/color]"; my $red_bold = "[color=Red][b]Red bold text[/b][/color]"; my $regex = qr/.+(?<=\])(.+?)(?=\[\/).+/; $bold =~ s/$regex/$1/; $red =~ s/$regex/$1/; $red_bold =~ s/$regex/$1/; print "\$bold: $bold\n"; print "\$red: $red\n"; print "\$red_bold: $red_bold\n"; __END__ __OUTPUT__ $bold: bold text $red: Red text text $red_bold: Red bold text