FULL PRODUCT VERSION : java version "1.6.0_02" Java(TM) SE Runtime Environment (build 1.6.0_02-b05) Java HotSpot(TM) Client VM (build 1.6.0_02-b05, mixed mode, sharing) ADDITIONAL OS VERSION INFORMATION : Linux localhost.localdomain 2.6.18-1.2798.fc6 #1 SMP Mon Oct 16 14:54:20 EDT 2006 i686 i686 i386 GNU/Linux A DESCRIPTION OF THE PROBLEM : If a regex for lookbehind grouping has multiple non-obvious length quantifiers, matching silently fails without throwing the important exception: Exception in thread "main" java.util.regex.PatternSyntaxException: Look-behind group does not have an obvious maximum length near index [i]nn[/i] STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : Write a regex which has a lookbehind group in which multiple non-obvious length quantifiers are used. Do matching or finding on strings using this regex. The regex doesn't throw exception for the wrong quantifiers failing silently instead. EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - The regex throws exception: Exception in thread "main" java.util.regex.PatternSyntaxException: Look-behind group does not have an obvious maximum length near index [i]nn[/i] ACTUAL - The regex fails silently. No messages are thrown. REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- public class LbBug{ public static void main(String[] args){ String[] dirs = { "P:\\ZEN\\NAT\\APPS\\ZMG\\Corel_WordPerfect_12sp3_Install\\Files\\Common\\Borland Shared", "P:\\ZEN\\NAT\\APPS\\ZMG\\Corel_WordPerfect_12sp3_Install\\Files\\Common\\Borland Shared\\BDE", "P:\\ZEN\\NAT\\APPS\\ZMG\\Corel_WordPerfect_12sp3_Install\\Files\\Common\\Borland Shared\\BDE\\disp.pak", "P:\\ZEN\\NAT\\APPS\\ZMG\\Corel_WordPerfect_12sp3_Install\\Files\\Common\\Borland Shared\\BDE\\bdeadmin.cnt", "P:\\ZEN\\NAT\\APPS\\ZMG\\Corel_WordPerfect_12sp3_Install\\Files\\Common\\Borland Shared\\BDE\\bdeadmin.exe", "P:\\ZEN\\NAT\\APPS\\ZMG\\Corel_WordPerfect_12sp3_Install\\Files\\Common", "P:\\ZEN\\NAT\\APPS\\ZMG\\Corel_WordPerfect_12sp3_Install\\Files\\Common\\InstallShield", "P:\\ZEN\\NAT\\APPS\\ZMG\\Corel_WordPerfect_12sp3_Install\\Files\\Common\\Corel", }; // pick only lines that end with a file extension String regex = "^.++(?<=\\w+\\.\\w+)$"; // should throw exception ... // note: it succeeds in throwing exception: "^.++(?<=\\w\\.\\w+)$" for (String s : dirs){ if (s.matches(regex)){ // ... but fails silently System.out.println(s); } } } } ---------- END SOURCE ----------