<?php

$string = 'img[style*="float: left"]
img: [style*="float: left"]
img( [style*="float: left"]
';


    $regex = '/"[^"]*"|([:(])\s+/ims';

    $output = preg_replace_callback(
        $regex,
        function ($matches) {
            if (array_key_exists (1, $matches)) {
                return $matches[1] ;
            }
            return $matches[0];
        },
        $string
    );
    echo "this is the output:"  . $output;