Hi,

I just upgraded from PCRE 8.10 to PCRE 8.21, and surprisingly found
the following behavior change:

$t='hello world test';
preg_match('/(another)?(\1?)test/', $t, $m);
var_dump($m);

on 8.10 I got:

array(3) {
  [0]=>
  string(4) "test"
  [1]=>
  string(0) ""
  [2]=>
  string(0) ""
}

Which is fine, but on 8.21 I got:

array(3) {
  [0]=>
  string(16) "hello world test"
  [1]=>
  string(0) ""
  [2]=>
  string(12) "hello world "
}

When (another)? didn't match, I would assume \1 also match an empty string,
however (\1?) part captured "hello world ", is this a bug or I
misunderstand the syntax?

Best regards,
Tiberius Teng

-- 
## List details at https://lists.exim.org/mailman/listinfo/pcre-dev 

Reply via email to