#!/usr/bin/perl use strict; use warnings; $/ = undef; my $text = ; $text =~ s!\[color=([^\]]+)\](.*?)\[/color\]!$2!gi; $text =~ s!\[image=([^\]]+)\]!!gi; $text =~ s!\[link=([^\]]+)\](.*?)\[/link\]!$2!gi; print $text; __DATA__ [color=#0000ff]Blue text[/color] with an image: [image=var.jpg] And a link to Google: [link=http://www.google.com]Google[/link].