Cita: var txt = '[URL name="Aqui va cualquiera cosa"]enlace[/URL] ' +
'un texto cualquiera ' +
'[yotube]enlace[/yotube] ' +
'otro texto cualquiera ' +
'[img]enlace[/img]';
txt = txt.replace(/\[(url([\sa-z]+="(.*))")\]([^\[]+)/gi, '<a href="$4">$3');
txt = txt.replace(/\[(YOTUBE)\]([^\[]+)/gi, '<iframe width="560" height="315" src="$2" frameborder="0" allowfullscreen>');
txt = txt.replace(/\[(IMG)\]([^\[]+)/gi, '<img src="$2"');
txt = txt.replace(/\[(\/URL)\]/gi, '</a>');
txt = txt.replace(/\[(\/YOTUBE)\]/gi, '</iframe>');
txt = txt.replace(/\[[^\]]+\]/gi, ' />');
console.log(txt);
el reemplazo que te he marcado ha de estar siempre al final