I am currently working at a project involving regex in php. I wanted to know why or how can I get this recursive regular expression to work in PHP:
/\(((?:(?:[^?+*{}()[\]\\|]+|\\.|\[(?:\^?\\.|\^[^\\]|[^\\^])(?:[^\]\\]+|\\.)*\]|\((?:\?[:=!]|\?<[=!]|\?>)?(?1)??\)|\(\?(?:R|[+-]?\d+)\))(?:(?:[?+*]|\{\d+(?:,\d*)?\})[?+]?)?|\|)*)\)/
It should match this text (for example):
{{"test":"([a-f0-9]{32})"},{"test2":"([a-z]{3})"}}
And the given results should be an array with:
[a-f0-9]{32}
[a-z]{3}
EDIT:
$from = '{{"test":"([a-f0-9]{32})"},{"test2":"([a-z]{3})"}}';
preg_match_all("/(((?:(?:[^?+*{}()[]\\|]+|\\.|[(?:\^?\\.|\^[^\]|[^\\^])(?:[^]\]+|\\.)*]|((?:\?[:=!]|\?<[=!]|\?>)?(?1)??)|(\?(?:R|[+-]?\d+)))(?:(?:[?+*]|\{\d+(?:,\d*)?\})[?+]?)?|\|)*))/", $from, $output_array, PREG_OFFSET_CAPTURE);
var_dump($output_array);