Edit report at https://bugs.php.net/bug.php?id=62041&edit=1
ID: 62041 Updated by: fel...@php.net Reported by: michael at squiloople dot com Summary: Fails when recursive group comes before reference -Status: Open +Status: Not a bug Type: Bug Package: PCRE related Operating System: Windows Vista PHP Version: 5.4.3 Block user comment: N Private report: N New Comment: Not a PHP issue. Assumption about bugs in pattern matching must be reported to http://pcre.org/ Thanks. Previous Comments: ------------------------------------------------------------------------ [2012-05-15 19:13:42] michael at squiloople dot com Description: ------------ When the recursive subpattern is captured after it is referenced: (?2)?::(?>((?1)(?>:(?1)){0,4}):)? It works fine. But when the capture comes before the reference it doesn't: ((?1)(?>:(?1)){0,4})?::(?>(?2):)? The problem is the final ":" as other characters work fine. Replacing it with "\:" or "[:]" does not help. Test script: --------------- // Test 1 preg_match('/^(?>([a-f0-9]{1,4})(?>:(?1)){5}:|(?!(?:.*[a-f0-9]:){6,})(?2)?::(?>((?1)(?>:(?1)){0,4}):)?)(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?>\.(?3)){3}$/iD', '0:0:0:0::0:255.255.255.255'); // Test 2 preg_match('/^(?>([a-f0-9]{1,4})(?>:(?1)){5}:|(?!(?:.*[a-f0-9]:){6,})((?1)(?>:(?1)){0,4})?::(?>(?2):)?)(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?>\.(?3)){3}$/iD', '0:0:0:0::0:255.255.255.255'); // Test 3 preg_match('/^(?>([a-f0-9]{1,4})(?>:(?1)){5}:|(?!(?:.*[a-f0-9]:){6,})((?1)(?>:(?1)){0,4})?::(?>(?2)!)?)(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(?>\.(?3)){3}$/iD', '0:0:0:0::0!255.255.255.255'); Expected result: ---------------- // Test 1 int(1) // Test 2 int(1) // Test 3 int(1) Actual result: -------------- // Test 1 int(1) // Test 2 int(0) // Test 3 int(1) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=62041&edit=1