Can a regular expression match whitespace or the start of a string?
I\'m trying to replace currency the abbreviation GBP with a £ symbol. I
It works in Perl:
$text = 'GBP 5 off when you spend GBP75'; $text =~ s/(\W|^)GBP([\W\d])/$1\$$2/g; printf "$text\n";
The output is:
$ 5 off when you spend $75
Note that I stipulated that the match should be global, to get all occurrences.