fork download
  1. <?php
  2.  
  3. $text = 'fdf sprintf_w($af, $a, $b) sprintf_w("dff fg", $a, $b)
  4. sprintf_w("dff, (fg) (fs)", $a, $b) sprintf_w("dff, fg", $a, $b)
  5. sprintf_w(\'dff, "fg"\', $a) fdf 45
  6.  
  7. sprintf_w( lol("dff") , $a)';
  8.  
  9. $regex = <<<'END'
  10. ~
  11. sprintf_w\(
  12. (
  13.   (?: " (?: [^"\\] | \\. )*+ "
  14.   | ' (?: [^'\\] | \\. )*+ '
  15.   | [^"',()]+
  16.   | \( (?1) \)
  17.   )*+
  18. )
  19. ~xs
  20. END;
  21.  
  22. echo preg_replace($regex, '_w($1)', $text);
Success #stdin #stdout 0.02s 23852KB
stdin
Standard input is empty
stdout
fdf _w($af), $a, $b) _w("dff fg"), $a, $b) 
_w("dff, (fg) (fs)"), $a, $b) _w("dff, fg"), $a, $b) 
_w('dff, "fg"'), $a) fdf 45

_w( lol("dff") ), $a)