mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-23 20:44:41 +02:00
6817475: named-capturing group name started with digit causes PSE exception
Need accept the digit as the first char of the group name Reviewed-by: alanb
This commit is contained in:
parent
a2b97ae3ec
commit
df65a88edb
2 changed files with 7 additions and 1 deletions
|
@ -2567,7 +2567,8 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
|
|||
break;
|
||||
case '<': // (?<xxx) look behind
|
||||
ch = read();
|
||||
if (Character.isLetter(ch)) { // named captured group
|
||||
if (ASCII.isLower(ch) || ASCII.isUpper(ch) || ASCII.isDigit(ch)) {
|
||||
// named captured group
|
||||
String name = groupname(ch);
|
||||
if (namedGroups().containsKey(name))
|
||||
throw error("Named capturing group <" + name
|
||||
|
|
|
@ -3389,6 +3389,11 @@ public class RegExTest {
|
|||
"gname",
|
||||
"yyy");
|
||||
|
||||
check(Pattern.compile("x+(?<8gname>y+)z+"),
|
||||
"xxxyyyzzz",
|
||||
"8gname",
|
||||
"yyy");
|
||||
|
||||
//backref
|
||||
Pattern pattern = Pattern.compile("(a*)bc\\1");
|
||||
check(pattern, "zzzaabcazzz", true); // found "abca"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue