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:
Xueming Shen 2009-03-20 16:22:59 -07:00
parent a2b97ae3ec
commit df65a88edb
2 changed files with 7 additions and 1 deletions

View file

@ -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

View file

@ -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"