1 person found this helpful
Im still not very good with these reg exp but this would work although Im sure I missed a cleaner way…
var st = "302304\n305678\r245675"; $.write(st); $.writeln(''); var ns = st.replace(/(\r|\n)/g,' '); $.write(ns);
This is the cleaner method you were looking for:
In this situation, even a simple \s would work, but that might not be what the OP was looking for...
the final result works:
stringName = stringName.replace(/(\r|\n|\s)/g,' ');
\r and \n are both \s characters.
This is functionally equivalent to what you have...
stringName = stringName.replace(/\s/g,' ');
I highly recommend browsing this website (lots of useful info there):