--- a/nashorn/src/jdk/nashorn/internal/runtime/RegExpMatch.java Thu Feb 07 14:58:41 2013 +0100
+++ b/nashorn/src/jdk/nashorn/internal/runtime/RegExpMatch.java Thu Feb 07 15:33:17 2013 +0100
@@ -77,4 +77,22 @@
public int length() {
return ((String)groups[0]).length();
}
+
+ /**
+ * Get the group with the given index or the empty string if group index is not valid.
+ * @param index the group index
+ * @return the group or ""
+ */
+ public Object getGroup(int index) {
+ return index >= 0 && index < groups.length ? groups[index] : "";
+ }
+
+ /**
+ * Get the last parenthesis group, or the empty string if none exists.
+ * @return the last group or ""
+ */
+ public Object getLastParen() {
+ return groups.length > 1 ? groups[groups.length - 1] : "";
+ }
+
}