I'm relatively new to regex, but my goal is to remove all html tags from the string, excluding the tags <br>and <a>using class = user. I want a custom this regular expression to clear the unnecessary html garbage from the contentedittable fields.
<br>
<a>
Hope one of your regex masters can help ...
Here is a test example: http://gskinner.com/RegExr/?2tpai
I think I'm close, but the class = end tag is currently selected as garbage when it is needed.
I would suggest you this:
<(?!a class='user'|br|/a)[^>]+>
i.e, html </a>, .
</a>
, , <a class='user', <...
<a class='user'
<
, html , - , , <a class='user'..../a> s, , , <a class='user'..../a> .
<a class='user'..../a>
HTML , HTML . . , XML HTML ? - .
, , "" "" , , . SQL ; , , , - .
HTML , <br> <a> DOM. ( , , , !). , , , JS , DOM, , .
JavaScript DOM, , quirksmode intro .
:
<?php $new_content = strip_tags($content, '<a><br>');
This will allow the use of all brand all aelements. Directly in this function, you do not have the ability to enable / disable element properties, such as class="user". This function always allows / prohibits specified elements with all properties.
br
a
class="user"