Re: about preg_replace, please help !

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Feb 3, 2008 8:00 PM, LKSunny <ad@xxxxxxxx> wrote:
> <?
> $txt = <<<eof
> aaaaaaaaa
> aaaaaaaaa
> aaaaaaaaa
>
> bbbbbbbb
> bbbbbbbb
>
> bbbbbbbb
> eof;
>
> //i just want replace "start to first \r\n\r\n"
> //how can i do ?
[snip]

<?
$txt = <<<eof
aaaaaaaaa
aaaaaaaaa
aaaaaaaaa

bbbbbbbb
bbbbbbbb

bbbbbbbb
eof;

$rep = preg_replace('/^(?s)(.*)(\r)?\n(\r)?\n/U','',$txt);

echo $rep."\n";
?>

    Note the optional \r and required \n.  This is because, if the
input/output is ever touching a non-Windows machine, it won't use \r\n
for newlines - only \n.

-- 
</Dan>

Daniel P. Brown
Senior Unix Geek
<? while(1) { $me = $mind--; sleep(86400); } ?>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux