1var regex1 = /a/,
2 regex2 = /b/,
3 regex3 = /c/,
4 samplestring = 'b';
5
6switch (true) {
7 case regex1.test(samplestring):
8 console.log("regex1");
9 break;
10 case regex2.test(samplestring):
11 console.log("regex2");
12 break;
13 case regex3.test(samplestring):
14 console.log("regex3");
15 break;
16}