Capture regexp group in a JScript variable

My goal is update track title artist albumartist metadata from the file name.
the demo of a file name is: 01. MyTitle - Artist1; Artist2.mp3
my regexp is: /^([0-9]+)(\.\s)(.*)(\s-\s)(.*)(\.[^\.]+)/gm
I have check it out in This Site
here is the screenshot from the site


there is 6 group in my regexp. I want to use
var GetTrack = Group 1
var GetTitle = Group 3
var GetArtist = Group 5
How can I create such variable for each group no?

One way to do it:

var n = "01. MyTitle - Artist1; Artist2.mp3";
var r = /^([0-9]+)(\.\s)(.*)(\s-\s)(.*)(\.[^\.]+)/gm;

DOpus.Output(n.replace(r, "$1"));
DOpus.Output(n.replace(r, "$2"));
DOpus.Output(n.replace(r, "$3"));
DOpus.Output(n.replace(r, "$4"));
DOpus.Output(n.replace(r, "$5"));
DOpus.Output(n.replace(r, "$6"));

Which will output:

01
. 
MyTitle
 - 
Artist1; Artist2
.mp3
1 Like

This method is works fine for me. If any one can, Please comment more method.