|
-
Dec 8th, 2004, 08:18 AM
#1
Is there a vbcrlf in javascript? And a replace? [Resolved]
If I give you a string and tell you to replace all the vbcrlfs with <br>s, how would you do it, using JavaScript?
Last edited by mendhak; Dec 8th, 2004 at 08:53 AM.
Reason: My snot did it!
-
Dec 8th, 2004, 08:20 AM
#2
Re: Is there a vbcrlf in javascript? And a replace?
PS: I hate javascript.
-
Dec 8th, 2004, 08:29 AM
#3
Re: Is there a vbcrlf in javascript? And a replace?
Answer pending.......
** Please Wait **
-
Dec 8th, 2004, 08:35 AM
#4
Re: Is there a vbcrlf in javascript? And a replace?
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
Last edited by visualAd; Dec 9th, 2004 at 09:35 AM.
Reason: Invalid Code - Amended (thank you CornedBee)
-
Dec 8th, 2004, 08:52 AM
#5
Re: Is there a vbcrlf in javascript? And a replace?
I knew my snot would amount to something someday. 
-
Dec 9th, 2004, 09:10 AM
#6
Re: Is there a vbcrlf in javascript? And a replace?
 Originally Posted by visualAd
Code:
var text = "lin1\r\nline2\r\nline3\r\n"
text.replace("/\r\n/g", "<br />\r\n"); // note first parameter must be a reg expression
Since it's got to be a regexp, remove the quotes around it.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Dec 9th, 2004, 09:18 AM
#7
Re: Is there a vbcrlf in javascript? And a replace? [Resolved]
Hang on, this is Javascript, not perl. If you don't put quotes around it, it won't be valid code.
-
Dec 9th, 2004, 09:22 AM
#8
Re: Is there a vbcrlf in javascript? And a replace? [Resolved]
Yes, it is. JavaScript has RegExp literals.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Dec 9th, 2004, 09:34 AM
#9
Re: Is there a vbcrlf in javascript? And a replace? [Resolved]
I never knew that. I guess the code I gave is invalid and I'll need to change it .
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|