CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
Matching a \n or a \r

 



muinatit
Deleted

Mar 21, 2001, 3:01 PM

Post #1 of 3 (1534 views)
Matching a \n or a \r Can't Post

I made up this regex...


Code
$value =~ s/(\n|\r)/ 
/g;

To look for a newline or a return (for compatibility), but when I see the return of something thrown through the filter, even if it's just a single line break, it comes out as two. Any ideas?

Jeffrey "muinatit" Lamoureux
muinatit@hotpop.com


kencl
User

Mar 23, 2001, 12:13 AM

Post #2 of 3 (1527 views)
Re: Matching a \n or a \r [In reply to] Can't Post

Window's systems use line feed AND carriage return to end a line, (IE \r\n) so since you are matching globally, when you come across this, you are replacing both of them.

>> If you can't control it, improve it, correlate it or disseminate it with PERL, it doesn't exist!


localfilmmaker
stranger

Apr 17, 2001, 1:18 PM

Post #3 of 3 (1505 views)
Re: Matching a \n or a \r [In reply to] Can't Post

Windows new-lines are different like he said. A better solution might be:
$value =~ s/\r?\n/< br>\n/g;
Except for the space in the br tag. ;-)

-localfilmmaker
Spencer Christensen
spencer@mecworks.com

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives