If I give you a string and tell you to replace all the vbcrlfs with <br>s, how would you do it, using JavaScript?
Printable View
If I give you a string and tell you to replace all the vbcrlfs with <br>s, how would you do it, using JavaScript?
PS: I hate javascript. :) :wave:
Answer pending.......
** Please Wait **
Code:var text = "line1\r\nline2\r\nline3\r\n"
text = text.replace(/\r\n/g, "<br />\r\n"); // note first parameter must be a reg expression
I knew my snot would amount to something someday. :)
:afrog:
Since it's got to be a regexp, remove the quotes around it.Quote:
Originally Posted by visualAd
Hang on, this is Javascript, not perl. If you don't put quotes around it, it won't be valid code. :confused:
Yes, it is. JavaScript has RegExp literals.
I never knew that. I guess the code I gave is invalid and I'll need to change it :eek2:.