fork download
  1. <?php
  2.  
  3. $reg = '/=["\']img\/([^"\']*)["\']/';
  4. $src = 'Some text ="img/image-file1.jpg" another text ="img/file-2.png" other text ="img/image3.jpg" final text';
  5. $final = preg_replace($reg, '={{media url="wysiwyg/$1"}}', $src);
  6. echo $final;
Success #stdin #stdout 0.02s 24196KB
stdin
Standard input is empty
stdout
Some text ={{media url="wysiwyg/image-file1.jpg"}} another text ={{media url="wysiwyg/file-2.png"}} other text ={{media url="wysiwyg/image3.jpg"}} final text