Repository: sjbarag/brs (js)

Issue:
RoRegex matchAll doesn't capture groups
`RoRegex#matchAll` currently doesn't capture any groups. [Link to the Brightscript docs](https://developer.roku.com/docs/references/brightscript/interfaces/ifregex.md#matchallstr-as-string-as-object) for expected behavior.

Pull request description:
fix(stdlib): RoRegex captures groups
# Change Summary

Closes #562 

Patch:
diff --git a/src/brsTypes/components/RoRegex.ts b/src/brsTypes/components/RoRegex.ts
index e5da42f..31abba0 100644
--- a/src/brsTypes/components/RoRegex.ts
+++ b/src/brsTypes/components/RoRegex.ts
@@ -162,11 +162,16 @@ export class RoRegex extends BrsComponent implements BrsValue {
             }
             this.jsRegex = new RegExp(source, flags);
             let arr = [];
-            let matches: string[] | null;
+            let matches: RegExpExecArray | null;
 
             while ((matches = this.jsRegex.exec(str.value)) !== null) {
-                let item = new BrsString(matches[0] || "");
-                arr.push(new RoArray([item]));
+                arr.push(
+                    new RoArray(
+                        matches
+                            .filter((match) => match !== undefined)
+                            .map((match) => new BrsString(match))
+                    )
+                );
             }
             return new RoArray(arr);
         },


Test patch:
diff --git a/test/e2e/BrsComponents.test.js b/test/e2e/BrsComponents.test.js
index 3445453..1fd9257 100644
--- a/test/e2e/BrsComponents.test.js
+++ b/test/e2e/BrsComponents.test.js
@@ -288,6 +288,18 @@ describe("end to end brightscript functions", () => {
             "789",
             " ]",
             " ]",
+            "Matches with groups: [ ",
+            "[ ",
+            "abx",
+            ", ",
+            "bx",
+            " ]",
+            "[ ",
+            "aby",
+            ", ",
+            "by",
+            " ]",
+            " ]",
         ]);
     });
 
diff --git a/test/e2e/resources/components/roRegex.brs b/test/e2e/resources/components/roRegex.brs
index 1f1e703..6dbdea7 100644
--- a/test/e2e/resources/components/roRegex.brs
+++ b/test/e2e/resources/components/roRegex.brs
@@ -27,4 +27,11 @@ sub main()
 
     ' make sure we can call matchall multiple times without error.
     regex.matchall("123 456 789")
+
+    regex = createObject("roRegex", "a(b.)", "i")
+    matches = regex.matchall("abx abyz")
+    print "Matches with groups: [ "
+    print "[ " matches[0][0] ", " matches[0][1] " ]"
+    print "[ " matches[1][0] ", " matches[1][1] " ]"
+    print " ]"
 end sub