First, thanks in advance for any help you can provide.
My regex is only capturing the first 3 instances of the string I'm trying to extract. Any ideas?
My code:
var objArgs         = WScript.Arguments;
var objFileSys      = new ActiveXObject("Scripting.FileSystemObject");
var objFolder       = objFileSys.getFolder(objArgs.Item(0));
var objTSetNum      = new RegExp("^ST.((\\d+)+)", "gm");
var objFile         = null;
var srcFile         = null;
for (var objFileEnum = new Enumerator(objFolder.files); !objFileEnum.atEnd(); objFileEnum.moveNext()) {
objFile = objFileSys.OpenTextFile(objFileEnum.item(), 1, false, 0);
srcFile = objFile.ReadAll();
objFile.Close();
// Check for different values in the TSet entries
// Build array to hold all TSet values found
var arrTSet;
while ((arrTSet = objTSetNum.exec(srcFile)) !== null) {
    // arrTSet = objTSetNum.exec(srcFile);
    WScript.Echo("arrTSet is: " + arrTSet);
    WScript.Echo("Length of arrTSet is: " + arrTSet.length)
    //var allTSetSame = true;
}
And a sample text file that has 5 instances of a line beginning with "ST*" - shouldn't all 5 be placed into the array?:
ISA*00*          *00*          *01*041199639      *08*9272590000     *150704*1131*U*00401*000001324*0*P*:
ST*865*0001
ST*865*0001
ST*865*0001
ST*865*0001
ST*865*0001
IEA*5*000001324
Any advice? My hunch is telling me that the exec() function is changing something, but I can't find any details as to what it might be changing.
Appreciate the help!
EDIT: Of course, once I posted it, I found the answer. exec() is stateful, so I needed to push each result returned into the array, similar to:
var arrTSet = [];
var match;  
  while (match = objTSetNum.exec(srcFile)) {
    arrTSet.push(+match[1]);            
}
Which was found here (giving credit): Why does Javascript's regex.exec() not always return the same value?