提交 e3ab1100 编写于 作者: S sherman

6817475: named-capturing group name started with digit causes PSE exception

Summary: Need accept the digit as the first char of the group name
Reviewed-by: alanb
上级 8c0acbf2
...@@ -2567,7 +2567,8 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) { ...@@ -2567,7 +2567,8 @@ loop: for(int x=0, offset=0; x<nCodePoints; x++, offset+=len) {
break; break;
case '<': // (?<xxx) look behind case '<': // (?<xxx) look behind
ch = read(); 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); String name = groupname(ch);
if (namedGroups().containsKey(name)) if (namedGroups().containsKey(name))
throw error("Named capturing group <" + name throw error("Named capturing group <" + name
......
...@@ -3389,6 +3389,11 @@ public class RegExTest { ...@@ -3389,6 +3389,11 @@ public class RegExTest {
"gname", "gname",
"yyy"); "yyy");
check(Pattern.compile("x+(?<8gname>y+)z+"),
"xxxyyyzzz",
"8gname",
"yyy");
//backref //backref
Pattern pattern = Pattern.compile("(a*)bc\\1"); Pattern pattern = Pattern.compile("(a*)bc\\1");
check(pattern, "zzzaabcazzz", true); // found "abca" check(pattern, "zzzaabcazzz", true); // found "abca"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册