Это работает в Perl:
$text = 'GBP 5 off when you spend GBP75';
$text =~ s/(\W|^)GBP([\W\d])/$1\$2/g;
printf "$text\n";
вывод:
$ 5 off when you spend $75
Примечание, что я предусмотрел, что соответствие должно быть глобальным, для получения всех случаев.
This Money class is terrific, and the article discusses why the developer made the decisions he did (compared to several other implementations).