3v4l.org

run code in 300+ PHP versions simultaneously
<?php $args = [ "(AAA/)(BBB/)(cc)", "(AAA/)xxxx(BBB/)(cc)", "(mystring123/)", "(\\mystring123\\)", ]; foreach ($args as $arg) { if (!preg_match_all("#^(?:\([/a-zA-Z0-9_\\\\-]+\))+$#", $arg, $matches, PREG_OFFSET_CAPTURE)) { var_dump($matches); echo 'The simple pattern "' . $arg . '" is not valid !'; //throw new \Exception('The simple pattern "' . $arg . '" is not valid !'); } }

preferences:
26.76 ms | 405 KiB | 5 Q