Regarding malformedness... //[^*\n]+/ Appears to be interpreted an empty regex "//" followed by gibberish...apparently one too many slashes at the beginning /\\/\*(.*?)\*\// /, escaped \, /, then more stuff outside the regex. My guess is that you fell victim to a couple of typos.