#!/usr/bin/perl use strict; use warnings; my $test = 'Ein [img=hallo] Test'; my $text = \$test; $$text =~ s/\[imgl\=\]/&#mark0;/g; $$text =~ s/\[img\=([^\]]+)\]//g; print $$text;