Also, instead of `new RegExp("\n","gm")` use `/\n/gm` so browser can pre-compile expression for repeated use. Only every use `new RegExp()` if the expression needs to change with every call.