#!/usr/bin/perl -w use strict; my $txt = "foo *text* bar *bat* bounce"; $txt =~ s/\*(.*?)\*/$1<\/em>/g; print $txt."\n";