Page 1 of 1

Why <br />

Posted: Tue Apr 15, 2003 4:42 am
by patrikG
nl2br keeps producing <br /> instead of simple <br> - not that I minded in the past, as both work, but now I have to summon up my very limited regEx-skills and find <br /> - which is just not as easy.

Why is it <br /> instead of <br>?
Does anyone know a nice simple regEx for <br />?

Posted: Tue Apr 15, 2003 4:53 am
by pootergeist
I don't know the regex, do know that <br /> is html4+ xhtml compliant though - all non-closing tags (ones without a <opener></closer> pair) in compliant code are closed prior to the greater-than symbol - eg <img .... /> etc

Posted: Tue Apr 15, 2003 5:42 am
by twigletmac
If you're using nl2br() then you don't have to do a regex to find <br /> if you're looking for end of lines - you can look for \n instead as the <br /> are just put next to the newline characters (\n) by nl2br().

Of course I don't know exactly what you need to match but if it is linebreaks then \n is the better and easier thing to search on.

Mac

Posted: Tue Apr 15, 2003 9:32 am
by patrikG
Yep - it works now. Thanks a lot :)