Re: new break tags
| From: | Christian Reiniger | Date: | Sun, 01 Jul 2001 08:21:50 +0000 |
| Subject: | Re: new break tags | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-55719@lists.php.net to get a copy of this message | ||
On Friday 29 June 2001 17:27, bill wrote:
> $breaks=preg_match_all("/<br>\s+<br>/i", "$text", $parts)
>
> and this
>
> preg_replace("/<br>\s+<br>/i","</P><P
> class=\"doserif\">",$text)
>
>
> Now that PHP 4.0.5 has changed the nl2br() function, it no longer
> replaces new lines with:
>
> <br>
>
> but instead with the new XHTML compliant break tags:
>
> <br />
>
> I tried just substituting the new tag into the above regular
> expressions to no avail. Any ideas?
Lemme guess, you tried
$breaks=preg_match_all("/<br/>\s+<br/>/i", "$text", $parts)
right? As "/" is the pattern delimiter this of course won't work.
Solution: Escape it:
$breaks=preg_match_all("/<br\/>\s+<br\/>/i", "$text", $parts)
Improved Solution: Make it more flexible:
$breaks=preg_match_all("/<br\s*\/?>\s+<br\s*\/?>/i", "$text",
$parts)
That should do the job
--
Christian Reiniger
LGDC Webmaster (http://lgdc.sunsite.dk/)
void sleep(){for(long int sheep=0;!asleep();sheep++);}