ID: 45260 Updated by: [EMAIL PROTECTED] Reported By: ralph at deboom dot biz Status: Bogus Bug Type: PCRE related Operating System: Debian Etch 4.0+ PHP Version: 5.2.6 New Comment:
The (?R) doesn't make sense to me in your regexp. I think that ((?:[.-][a-z0-9]+)*) would be ok. :) PS: Any other question, not reporting bug send to my email. Previous Comments: ------------------------------------------------------------------------ [2008-06-13 17:19:32] ralph at deboom dot biz Ok, I've got quite the knowledge with PCRE regexp's but is it possible with PCRE to generate this result I wanted? Because quite frankly I've tried on various ways. As in the whole day... ------------------------------------------------------------------------ [2008-06-13 16:46:35] [EMAIL PROTECTED] Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php "If a capturing subpattern is matched repeatedly, it is the last portion of the string that it matched that is returned." - http://pcre.org/pcre.txt ------------------------------------------------------------------------ [2008-06-13 13:32:03] ralph at deboom dot biz $value = 'sub.sub2.sub3.sub4.domain.ext'; if (preg_match("/^(([a-z0-9]+)(([\.|\-]{1}[a-z0-9]+)|(?R))*\.([a-z]{2,6}))$/i",$value,$match)) { print_R($match); } Thanks to a crappy textarea form I cant properly outline the code.. just indent it yourself ^^ ------------------------------------------------------------------------ [2008-06-13 13:29:48] ralph at deboom dot biz Description: ------------ A recursive subpattern turns out to overwrite data of the previous matched call... Thus it will only show the last recursive match it made in the pattern... Reproduce code: --------------- $value = 'sub.sub2.sub3.sub4.domain.ext'; if (preg_match("/^(([a-z0-9]+)(([\.|\-]{1}[a-z0-9]+)|(?R))*\.([a-z]{2,6}))$/i", $value, $match)) { print_R($match); } Expected result: ---------------- Array ( [0] => sub.sub2.sub3.sub4.domain.ext [1] => sub.sub2.sub3.sub4.domain.ext [2] => sub [3] => .sub2.sub3.sub4.domain [4] => .sub2.sub3.sub4.domain [5] => ext ) Actual result: -------------- Array ( [0] => sub.sub2.sub3.sub4.domain.ext [1] => sub.sub2.sub3.sub4.domain.ext [2] => sub [3] => .domain [4] => .domain [5] => ext ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=45260&edit=1
