Still ereg fails NL/CR despite numerous trials
| From: | Wingo Chan | Date: | Fri, 03 Nov 2000 14:39:58 +0000 |
| Subject: | Still ereg fails NL/CR despite numerous trials | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-23581@lists.php.net to get a copy of this message | ||
I've tried a lot of suggestions from the list to get rid of \n & \r, but
I still failed. Could some one please lend me a hand?
What I wanted to do was to eregi some repetitive info from a (large)
portion of a remote html file. I tried both fread() and file(). When I
examined the content, \n\r were all around: in the middle of a line as
well as at the beginning of consecutive lines. I tried numerous ways to
get rid of them including:
nl2br
eregi_replace("[\n\r]","<br>",$rec)
eregi_replace("[\015\012]","<br>",$rec)
eregi_replace("\n","<br>",$rec)
eregi_replace("\\n","<br>",$rec)
.
.
you name it.
I still couldn't get rid of them and therefore my subsequent eregi
failed.
I even narrowed down my regex on the following text but couldn't get a
match:
$test_str = "<HTML TAGs> Available <HTML TAGs>1. Beginning Php 4
by Jon Blan"
(Mind you: \n\r's are not shown here.)
My regex was:
eregi_replace("(php)","<font
color='red'>\\1</font>","$test_str");
I'm stuck now. Your leading through will be highly appreciated.
Thank you very much in advance.
PHP & regex newbie,
Wingo Chan