[Javascript] Looking for CR/LF

Tim Makins spindrift at oceanfree.net
Tue Nov 9 10:34:02 CST 2004


Good point Mike - well, I was rather concerned about the space taken up by
an array of 3-6000 entries. Cut it again, and it would be 6000 x whatever.
Perhaps this is not an issue, but I always imagine that arrays take lots of
space. Wonder how I could check if its a problem - perhaps look at the
Resources meter, maybe...

Tim in Ireland.


----- Original Message ----- 
From: "Mike Dougherty" <mdougherty at pbp.com>
To: "[JavaScript List]" <javascript at LaTech.edu>
Sent: Tuesday, November 09, 2004 3:09 PM
Subject: Re: [Javascript] Looking for CR/LF


Why aren't you using split()?

First split on CR/LF, then iterate the array and split each element on ","
and you'll have access
to each 'word' on each line.

I'd imagine split() would be faster than iterating the string character by
character

On Tue, 9 Nov 2004 14:27:47 -0000
  "Tim Makins" <spindrift at oceanfree.net> wrote:
>Well, I don't actually want to cut up the string, or change it in any way.
>All I wanted was to be able to loop through the string, character by
>character, and know when I had reached a LF/CR. I will check the new
>possibilities opened up by:
>
>textarea_string.indexOf("\r\n", last_line + 1)
>
>unless anyone has other ideas.
>
>Thanks,
>Tim in Ireland.
>
>
>
>----- Original Message ----- 
>From: "Allard Schripsema" <allard-schripsema at procergs.rs.gov.br>
>To: "[JavaScript List]" <javascript at LaTech.edu>
>Sent: Tuesday, November 09, 2004 1:00 PM
>Subject: RE: [Javascript] Looking for CR/LF
>
>
>> Hi Tim,
>>
>> What takes to much time, creating the string or cutting up the string?
>> Show us the part of the code that is problematic.
>> I had a performance problem here which had to do with long strings and
got
>> some umbelievable results:
>> building a list of 200 lines ( and a lot of columns) went from 70 secs to
>> 6.7 secs using some tricks like extra buffers....
>>
>> Allard
>>
>>
>>
>>
>> -----Original Message-----
>> From: javascript-bounces at LaTech.edu
>> [mailto:javascript-bounces at LaTech.edu]On Behalf Of Tim Makins
>> Sent: Tuesday, November 09, 2004 9:14 AM
>> To: [JavaScript List]
>> Subject: [Javascript] Looking for CR/LF
>>
>>
>> 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
>>
>>
>> _______________________________________________
>> Javascript mailing list
>> Javascript at LaTech.edu
>> https://lists.LaTech.edu/mailman/listinfo/javascript
>>
>
>_______________________________________________
>Javascript mailing list
>Javascript at LaTech.edu
>https://lists.LaTech.edu/mailman/listinfo/javascript
>
>
>
>__________________________________________________________
>This message was scanned by ATX
>9:54:53 AM ET - 11/9/2004

_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript




More information about the Javascript mailing list