|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2012-05-20 22:02 UTC] felipe@php.net
[2012-05-20 22:02 UTC] felipe@php.net
-Status: Open
+Status: Not a bug
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 15:00:02 2025 UTC |
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)