On Nov 26, Quelance said:

>replace any matched spaces with  
>replace a new line with <br>

Um, newline is a space.

>while(<INFILE>) {
>  s/\s/&nbsp;/;  #replace spaces with &nbsp;
>  s/\n/<br>\n/;   #replace newlines with <br>
>  print $_;
>  print OUTFILE $_;
>}

You probably want to change s/\s/&nbsp;/ to s/[ \t]/&nbsp;/g.  That does
two things differently:

  1. uses [ \t] to match a space or a tab, instead of \s (because \s
     matches \n)
  2. s///g <-- substitutes GLOBALLY, that is, replaces all occurrences

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to