The replace function expects the first argument (the regular expression) to be passed without surrounding quotes. I know it looks odd, but that's how the function works.
The snippet below worked for me:
Joined: Nov 10, 2006
Thanks, it worked for me too. can you please explain how this regular expression works?
Joined: Jan 20, 2005
The format for the regular expression argument is "/regular expression/expression modifiers". So the base regular expression /\r\n/ is the same one you used to begin with. By default, the regular expression only selects the first occurrence of the specified pattern. To specify that you want to select, and eventually replace, all occurrences of the pattern you need to add the "g" (for global) expression modifier, /\r\n/g. So now when this gets passed to the replace function, all instances of "\r\n" will be replaced with a comma. Instead of just the first one.