Skip to content

Commit b83b53d

Browse files
committed
Matcher.getGroup(int) was passing undefined; should be null
1 parent 15241a9 commit b83b53d

File tree

1 file changed

+3
-1
lines changed
  • sources/net.sf.j2s.java.core/src/java/util/regex

1 file changed

+3
-1
lines changed

sources/net.sf.j2s.java.core/src/java/util/regex/Matcher.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,9 @@ public String group(int group) {
953953
throw new IllegalStateException("No match found");
954954
if (group < 0 || group > groupCount())
955955
throw new IndexOutOfBoundsException("No group " + group);
956-
return results[group];
956+
// this array is coming from JavaScript RegExp; some values may be "undefined"
957+
// so we force them to be null.
958+
return results[group] == null ? null : results[group];
957959
// if ((groups[group*2] == -1) || (groups[group*2+1] == -1))
958960
// return null;
959961
// return getSubSequence(groups[group * 2], groups[group * 2 + 1]).toString();

0 commit comments

Comments
 (0)