I have this code in my PHP page:
$regex = '/<img.*?>/';
I need that preg_match replace only images that don't have class="nopopup"
What is the correct regular expression?
I have this code in my PHP page:
$regex = '/<img.*?>/';
I need that preg_match replace only images that don't have class="nopopup"
What is the correct regular expression?
 
    
    I propose a solution that avoids complicated regular expressions. Rather, keep your simple regex that looks for image elements, and use preg_replace_callback. For each match, this function will call a function defined by you and passes it that match. Then, you use a simple regular expression that scans the match for the string class="nopopup". It it's there, perform the replacement. If it's not there, you just return the original string.
