Why ??? It checks nested parenteses
$variation="(( ( (?>[()]+) | (?R) )* ))";
preg_match_all("% \d \s* $variation \s* %Sxms", "6 (in1a (in2) in1b)", $out, PREG_SET_ORDER); echo "<pre>"; print_r($out); echo "</pre>";
If I remove \d, it works fine
You have a space after the first %, so its looking for a <blank>\d, at the beginning of the string, but there is no blank before the "6"
According to the user guide (http://www.php.net/manual/en/pcre.pattern.modifiers.php) blank spaces should ignored:
x (PCRE_EXTENDED) If this modifier is set, whitespace data characters in the pattern are totally ignored except when escaped or inside a character class, and characters between an unescaped # outside a character class and the next newline character, inclusive, are also ignored. This is equivalent to Perl's /x modifier, and makes it possible to include comments inside complicated patterns. Note, however, that this applies only to data characters. Whitespace characters may never appear within special character sequences in a pattern, for example within the sequence (?( which introduces a conditional subpattern.