fork download
  1. <?php
  2.  
  3. $string = 'img[style*="float: left"]
  4. img: [style*="float: left"]
  5. img( [style*="float: left"]
  6. ';
  7.  
  8.  
  9. $regex = '/"[^"]*"|([:(])\s+/ims';
  10.  
  11. $regex,
  12. function ($matches) {
  13. if (array_key_exists (1, $matches)) {
  14. return $matches[1] ;
  15. }
  16. return $matches[0];
  17. },
  18. $string
  19. );
  20. echo "this is the output:" . $output;
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
this is the output:img[style*="float: left"]
img:[style*="float: left"]
img([style*="float: left"]