3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = 'location in [chambre, cuisine, salle-de-bain, jardin]'; $regex = <<<REGEX / [a-zA-Z]+ (?= \s+in\s+\[\s* [a-zA-Z-]+\s* (?:,\s*[a-zA-Z-]+\s*)* \] ) | \G(?!^) (?: \s+in\s+\[\s* | \s*,\s* ) \K [a-zA-Z-]+ /x REGEX; preg_match_all($regex, $input, $matches); var_export($matches[0]);

preferences:
74.08 ms | 405 KiB | 5 Q