3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $passes = ["fo\"obar", "foobar\"", "foobar\\\\\"", "foo\\\"\"bar"]; $expect = '{"foo":{"password":"****"}}'; foreach ($passes as $pass) { $json = json_encode(["foo"=>["password"=>$pass]]); echo $expect; echo ""; echo preg_replace('{("password"\s*:\s*)"(?:[^"\\\\]|(?:\\\\.))*"}', '$1"****"', $json); if ($expect !== preg_replace('{("password"\s*:\s*)"(?:[^"\\\\]|(?:\\\\.))*"}', '$1"****"', $json)) { echo "Password $pass is out of this league!"; exit(1); } } echo "Filter test ok!";
based on M5UD2
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.2.0
{"foo":{"password":"****"}}{"foo":{"password":"****"}}{"foo":{"password":"****"}}{"foo":{"password":"****"}}{"foo":{"password":"****"}}{"foo":{"password":"****"}}{"foo":{"password":"****"}}{"foo":{"password":"****"}}Filter test ok!