Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace HTML entities with regular expression [closed]

I would like a regular expression in PHP to find all HTML entities such as "<br /> <br /> ..etc. " in order to remove them from a long string.

like image 315
Bajrang Avatar asked Jan 10 '12 10:01

Bajrang


1 Answers

This one removes alpha, decimal and hex HTML entities:

$text = preg_replace('/&(?:[a-z\d]+|#\d+|#x[a-f\d]+);/i', '', $text);
like image 199
ridgerunner Avatar answered Sep 22 '22 07:09

ridgerunner