s/ substitute \* a star (.*?) then a group of arbitrary characters (but only match once, see below) \* then another star / replace it with $1<\/em> what we just got, surrounded by 's /g; do this across the entire string;