简体   繁体   中英

Regular expression needed for PHP

Can anybody tell me a regular expression to use within some PHP to find the following:

  1. <p>&nbsp;</p> with any variation of white space between those tags

  2. <p><br/> again with any variation of white space between those tags

Any help appreciated, thanks!

If you want to parse XML (or HTML) you should think about using a XML parser instead of regex. It would be more efficient.

PHP already contains an XML parser which is good for you :)


Resources :

On the same topic :

Pretty straightforward (and folks, because he's asking for things with only whitespace between them, not nested tags or attributes or any of that, a parser isn't necessary in this case...)

/<p>\s+<\/p>/

/<p>\s+<br\/>/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM