Re: [PHP] new break tags

2001-07-01 Thread Christian Reiniger

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,/PP 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++);}

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] new break tags

2001-06-29 Thread bill

I'm trying to fix two regular expressions to work with the new break
tags.

This

$breaks=preg_match_all(/br\s+br/i, $text, $parts)

and this

preg_replace(/br\s+br/i,/PP 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?

kind regards,

bill hollett


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]