Format plain text using JScript? 
Author Message
 Format plain text using JScript?

Is there anybody who has an idea how to remove <cr> in a txt-string.
I read a multiline text-file from the filesystem and assign this to a
variable. However I want to remove blank lines, linefeeds and carriage
returns to compress the text.

I've tried search and replace, replacing with re=\n; s.replace(re, " ");
In fact i've tried with both \n and \r, still the string print out with no
difference at all.

Any ideas?

JE Holen



Fri, 23 Aug 2002 03:00:00 GMT  
 Format plain text using JScript?
Hi

Assuming str is holding the data

var re = /\n/g;
var fstr = str.replace(re,"<br>");

--
Best Regards
 Vidar Petursson Microsoft MVP
http://www.icysoft.com


No matter where you go there you are
-

Quote:
> Is there anybody who has an idea how to remove <cr> in a txt-string.
> I read a multiline text-file from the filesystem and assign this to a
> variable. However I want to remove blank lines, linefeeds and carriage
> returns to compress the text.

> I've tried search and replace, replacing with re=\n; s.replace(re, " ");
> In fact i've tried with both \n and \r, still the string print out with no
> difference at all.

> Any ideas?

> JE Holen



Fri, 23 Aug 2002 03:00:00 GMT  
 Format plain text using JScript?
howdy--

multilineString.replace(/\r\n/g," ");

T

Quote:

> Is there anybody who has an idea how to remove <cr> in a txt-string.
> I read a multiline text-file from the filesystem and assign this to a
> variable. However I want to remove blank lines, linefeeds and carriage
> returns to compress the text.

> I've tried search and replace, replacing with re=\n; s.replace(re, " ");
> In fact i've tried with both \n and \r, still the string print out with no
> difference at all.

> Any ideas?

> JE Holen



Sun, 25 Aug 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. to format plain text

2. Convert MSDOS-text Format into contemporary text format

3. Format LaTeX into plain ASCII files with new version of LameTeX (1.1)

4. Plain Text -> Postscript

5. HELP NEEDED: Software to transform plain text files (UNIX) to PDF

6. plain text

7. sample code needed to open plain text file and use as excel97 file

8. How to convert into plain text?

9. TIFF and PLain Text 2 PS for Print tool

10. converting plain text file?

11. convert postscript to plain text or to html?

12. Converting PostScript files to plain ASCII text

 

 
Powered by phpBB® Forum Software