3v4l.org

run code in 300+ PHP versions simultaneously
<?php $strings = [ '"test"', 'test', '\'te\'st"\'', '\'test\'', '\'"test"\'', '\'"te"st"\'', 'This is a test"""""".', 'test\'\'\'\'\'""""""""', 'test\'\'\'\'\'""""""""', '\'\'\'\'"""\'\'\'test\'\'"""\'\'\'', '\'\'\'\'\'""""\'\'' ]; $pattern = "/^['\"]*(.*?)['\"]*$/"; foreach ($strings as $string) { echo preg_replace($pattern, '$1', $string) . PHP_EOL; }

preferences:
35.71 ms | 404 KiB | 5 Q