$ cat foo.pl #!/usr/bin/perl -w use strict; use warnings; my $text = '
Some text
,
an a'; $text =~ s~(.*?)<\/font>~\[color=$2\]$5\[/color\]~ig; print $text . "\n"; $ ./foo.pl [color=blue]
Some text[/color],
an a $