Scriptman Scriptman - 2 months ago 8
PHP Question

preg_match_all except if tag has class

I have a regex which replaces shortcodes in my texts.


<textarea class="ignoreShortCodes">[test_code]</textarea>

Now both
blocks are going to replaced, but I don't want this.

Now here is my regex:


Please note, a shortcode can contain arguments like:

[test_code name="test"]

Who can help me with this issue?


You can use a negative lookahead:


which will match every lignes that doesn't contain the class ignoreShortCodes