I need some help with building a regular expression in Javascript. The idea is to remove anchor tags pasted from a Word Document.

The regular expression must take the text example below, remove all the <a name> (opening and closing) tags and only leave <i><b>1 VISION AND MISSION</b></i> (ignore the <b> and <i> for now, I have an expression to replace them with <strong> and <em>)

<a name="_Toc153934773"></a><a name="_Toc121546821"></a><a name="_Toc121541109"><i><b>1 VISION AND MISSION</b></i></a>

If I use the following expression, it removes the first 2 tag sets, ie the ones without any text enclosed, but leaves the third one intact
ie. returns <a name="_Toc121541109"><i><b>1 VISION AND MISSION</b></i></a>

code = code.replace(/<a name=[^>]*>([^<\/a>])<\/a>/gi,"$1");

The first and the last parts are fine (green), it's the red bit I'm struggling with

(/<a name=[^>]*>([^<\/a>])<\/a>/gi,"$1");

the red part is supposed to find all text excluding </a> and store it in a backreference, which is then used as the replacement string $1.
To group <\/a> in order to treat it it as a phrase, you should enclose it in (), and that's where my confusion comes in, when does it treat it as a backreference and when as a grouping clause?

Your help is appreciated