<?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; }
You have javascript disabled. You will not be able to edit any code.