Reputation: 521
I would like to replace symbols with HTMLtags. For example:
This :is: some :text: that could also look :a: bit :different:.
should become
This <span id="selected">is</span> some <span id="selected">text</span> that could also look <span id="selected">a</span> bit <span id="selected">different</span>.
Upvotes: 1
Views: 193
Reputation: 4984
(:)(.+?)\1
using \1
will allow you to change out the ":" to other characters and make sure the closing matches.
Upvotes: 1
Reputation: 1979
$str = "This :is: some :text: that could also look :a: bit :different:";
$str =~ s/:(\w+):/<span id='selected'>$1<\/span>/g;
print $str;
Upvotes: 1