$string =~ s/$regex/'bar'/g; # This will print ... "this is a 'bar'" # but with "/ge" .... "this is a bar"