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