Answer the question
In order to leave comments, you need to log in
What is the correct way to build a regular expression preg_replace?
Not strong in regulars. Help me compose a regular expression to remove all attributes/styles from tags, except for tags: img,table,td,tr,a
I only got as far as removing all attributes myself:
$html_no_attr = preg_replace('#(</?\w+)(?:\s(?:[^<>/]|/[^<>])*)?(/?>)#ui', '$1$2', $html);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question