This would work correctly:
replace(/\r\n/g, "\n").replace(/\r/g, "\n")
BTW since both replace() have simple expressions it's 2.5 times faster (Chrome) than currently used (\r|\n){1,2}, you can test it by executing s=prompt(); console.time(1); for(i=0;i<1000;i++) ss=s.replace(/\r\n/g, "\n").replace(/\r/g, "\n"); console.timeEnd(1); in the console (paste something big in the prompt window, for example node-parserlib.js contents. Then compare with the current code's regexp.