[Javascript] Looking for CR/LF

Tim Makins spindrift at oceanfree.net
Tue Nov 9 08:21:47 CST 2004


Thanks Flavio. From your idea, I tried

textarea_string = F1.textbox.value;
String.prototype.replace = replace_string;
var replaced_string = textarea_string.replace("\r\n", ";");

which does work, and keeps the replacing down to 1 per line.

Tim in Ireland.

----- Original Message ----- 
From: "Flavio Gomes" <flavio at economisa.com.br>
To: "[JavaScript List]" <javascript at LaTech.edu>
Sent: Tuesday, November 09, 2004 12:27 PM
Subject: Re: [Javascript] Looking for CR/LF


> Maybe:
>
>   alert(document.F1.textbox.value.split("\r\n").length); // (or \n\r .. I
never remember)
>
>  But it might be a bit slow also.
>
> --
> Flavio Gomes
> flavio at economisa.com.br
>
>
>
> Tim Makins wrote:
>
> >Hi to all: I have a text box, and will paste in to it multi-line text
such
> >as:
> >
> >apples,1,4545,23,foo,foo
> >pear,34,32,56,foo,foo
> >banana,765,4465,332,frog,bat
> >
> >I will then grab the contents and put it into a string.
> >
> >What I want to do then is to separate each *line* in the string; to do
that
> >I need to loop through it until I find the carriage-return/linefeed.
> >
> >I *could* do it using
> >
> >textarea_string = escape(F1.textbox.value);
> >String.prototype.replace = replace_string;
> >var replaced_string = textarea_string.replace("%0D%0A", ";");
> >
> >and then look for ';' but I might have 3000 lines to deal with, which
takes
> >too long, and converts lots of other things I don't want converting.
> >
> >How else can I spot the position of each carriage-return/linefeed ???
> >
> >Tim in Ireland.
> >
> >
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>




More information about the Javascript mailing list