<?php $strings = [ "\"Test\"", "'Test'", "`Test`", "(Test)", "Test\"", "'Test", "Test`", "(Test", "\"Test'", "'Test\"", "`Test", "Test)", ]; $pattern = '/(?|(["\'`])(Test)\1|\(((Test)\)))/'; foreach ($strings as $string){ $isMatch = preg_match($pattern, $string, $matches); if ($isMatch) { echo "Match $string ==> " . $matches[2] . PHP_EOL; } }
You have javascript disabled. You will not be able to edit any code.