If you want to do this one document at a time (or automate > batch it on a whole folder later) use this:
var workingName = app.activeDocument.name;
if(workingName.match(/(v1)/ig)){
//do something
} else if (workingName.match(/(v2)/ig)){
//do something
} else if (workingName.match(/(v3)/ig)){
//do something
}
If you want to loop through all open documents use this:
for (i = 0; i < documents.length; i++){
var curDoc = app.activeDocument = app.documents;
var workingName = curDoc.name;
if(workingName.match(/(v1)/ig)){
//do something
} else if (workingName.match(/(v2)/ig)){
//do something
} else if (workingName.match(/(v3)/ig)){
//do something
}
}
NOTE: the 'i' toward the end of each regex pattern makes this case insensitive....if you want it to be case sensitive get rid of the 'i'. Also, in the second option if the "do something" part includes closing the document, this will throw off the loop. In that case change the iteration to count backwards like this:
for (i = app.documents.length - 1; i >= 0; i--)