in reply to How to expand a string

A simple (but inefficient) way is:
$_ = ' RAGGTS '; while (/[RS]/) { s/ ([A-Z]*)R([A-Z]*) / $1A$2 $1G$2 /g; s/ ([A-Z]*)S([A-Z]*) / $1C$2 $1G$2 /g; } print;