We recently had a bug, after a fellow developer changed a RegExp literal into a constructor call, and I was wondering why there is any difference at all. The exact code was
var parts = new RegExp("/rt:([^@]+)@(\d+)/").exec(tag);
vs the original of
var parts = /rt:([^@]+)@(\d+)/.exec(tag);
When tag is, for example rt:60C1C036-42FA-4073-B10B-1969BD2358FB@00000000077, the first (buggy) call returns null, while the second one returns["rt:60C1C036-42FA-4073-B10B-1969BD2358FB@00000000077", "60C1C036-42FA-4073-B10B-1969BD2358FB", "00000000077"]
Needless to say, I reverted the change, but I'd like to know why is there such a difference in the first place.