-
Bug
-
Resolution: Unresolved
-
P4
-
8, 9
-
Cause Known
-
generic
-
generic
FULL PRODUCT VERSION :
java version "1.8.0_73"
Java(TM) SE Runtime Environment (build 1.8.0_73-b02)
Java HotSpot(TM) 64-Bit Server VM (build 25.73-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
WIndows 10, online Java, etc.
A DESCRIPTION OF THE PROBLEM :
After matching the regular expression ab(?:a(c))*ac over the string abacacac,
querying the start position of the matched group (c) returns 7, which is not possible since the c at position c is matched by the last c of the regular expression. And (?: ...) is consuming, so there is no look-ahead.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Paste the following code into an online java IDE such as: https://www.compilejava.net/
import java.util.regex.*;
public class HelloWorld
{
public static void main(String[] args)
{
Pattern p = Pattern.compile("ab(?:a(c))*ac");
Matcher m = p.matcher("abacacac");
m.find();
System.out.println(m.start(1));
}
}
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.regex.*;
public class HelloWorld
{
public static void main(String[] args)
{
Pattern p = Pattern.compile("ab(?:a(c))*ac");
Matcher m = p.matcher("abacacac");
m.find();
System.out.println(m.start(1));
}
}
---------- END SOURCE ----------
java version "1.8.0_73"
Java(TM) SE Runtime Environment (build 1.8.0_73-b02)
Java HotSpot(TM) 64-Bit Server VM (build 25.73-b02, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
WIndows 10, online Java, etc.
A DESCRIPTION OF THE PROBLEM :
After matching the regular expression ab(?:a(c))*ac over the string abacacac,
querying the start position of the matched group (c) returns 7, which is not possible since the c at position c is matched by the last c of the regular expression. And (?: ...) is consuming, so there is no look-ahead.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Paste the following code into an online java IDE such as: https://www.compilejava.net/
import java.util.regex.*;
public class HelloWorld
{
public static void main(String[] args)
{
Pattern p = Pattern.compile("ab(?:a(c))*ac");
Matcher m = p.matcher("abacacac");
m.find();
System.out.println(m.start(1));
}
}
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.regex.*;
public class HelloWorld
{
public static void main(String[] args)
{
Pattern p = Pattern.compile("ab(?:a(c))*ac");
Matcher m = p.matcher("abacacac");
m.find();
System.out.println(m.start(1));
}
}
---------- END SOURCE ----------
- duplicates
-
JDK-8187083 Regex: Capturing groups inside a lookahead aren't backtracked
-
- Open
-
-
JDK-8187080 Regex: Nested capturing groups under greedy repetition aren't backtracked
-
- In Progress
-