'Matchall only retrieves 5 results into a collection

I am using powerapps to retrieve data back from a automate flow.

I have a HTTP request then getting the response back using a variable.

The varVersionHistory variable gives json as string:

{  "versionhistorymetadata": "{\"Version\":\"11.0\",\"ModifiedDateTime\":\"Wednesday, Mar 16, 2022, 5:44 PM\",\"ModifiedBy\":\"MG\",\"ChangeSummary\":\"MG changes\"};{\"Version\":\"10.0\",\"ModifiedDateTime\":\"Wednesday, Mar 16, 2022, 4:58 PM\",\"ModifiedBy\":\"DP\",\"ChangeSummary\":\"test\"};{\"Version\":\"9.0\",\"ModifiedDateTime\":\"Wednesday, Mar 16, 2022, 4:34 PM\",\"ModifiedBy\":\"DP\",\"ChangeSummary\":\"test\"};{\"Version\":\"8.0\",\"ModifiedDateTime\":\"Wednesday, Mar 16, 2022, 4:04 PM\",\"ModifiedBy\":\"DP\",\"ChangeSummary\":\"Add a comment v5\"};{\"Version\":\"7.0\",\"ModifiedDateTime\":\"Wednesday, Mar 16, 2022, 4:03 PM\",\"ModifiedBy\":\"DP\",\"ChangeSummary\":\"Add a comment v2\"};{\"Version\":\"6.0\",\"ModifiedDateTime\":\"Wednesday, Mar 16, 2022, 1:29 PM\",\"ModifiedBy\":\"DP\",\"ChangeSummary\":null};{\"Version\":\"5.0\",\"ModifiedDateTime\":\"Tuesday, Mar 15, 2022, 2:37 PM\",\"ModifiedBy\":\"DP\",\"ChangeSummary\":null};{\"Version\":\"4.0\",\"ModifiedDateTime\":\"Monday, Mar 14, 2022, 6:44 PM\",\"ModifiedBy\":\"DP\",\"ChangeSummary\":null};{\"Version\":\"3.0\",\"ModifiedDateTime\":\"Monday, Mar 14, 2022, 6:40 PM\",\"ModifiedBy\":\"DP\",\"ChangeSummary\":null};{\"Version\":\"2.0\",\"ModifiedDateTime\":\"Monday, Mar 14, 2022, 11:02 AM\",\"ModifiedBy\":\"DP\",\"ChangeSummary\":null};{\"Version\":\"1.0\",\"ModifiedDateTime\":\"Monday, Mar 14, 2022, 10:58 AM\",\"ModifiedBy\":\"DP\",\"ChangeSummary\":null}"}

I am trying to covert that into a collection. I have this code which is working but it only gives me the top 5 rows in a collection.

ClearCollect(colVersionHistory,MatchAll(varVersionHistory,"\{""Version"":""(?<Version>[^""]*)"",""ModifiedDateTime"":""(?<ModifiedDateTime>[^""]*)"",""ModifiedBy"":""(?<ModifiedBy>[^""]*)"",""ChangeSummary"":""(?<ChangeSummary>[^""]*)""\}"))

Can you please help in fixing this? Thanks!



Solution 1:[1]

You need to use

ClearCollect(colVersionHistory,MatchAll(varVersionHistory,"\{""Version"":""(?<Version>[^""]*)"",""ModifiedDateTime"":""(?<ModifiedDateTime>[^""]*)"",""ModifiedBy"":""(?<ModifiedBy>[^""]*)"",""ChangeSummary"":(?:""(?<ChangeSummary>[^""]*)""|(?<ChangeSummary>\w+))\}"))

See the regex demo.

Note the "ChangeSummary":(?:"(?<ChangeSummary>[^"]*)"|(?<ChangeSummary>\w+)) regex part: now, it matches "ChangeSummary": and then either of the two patterns:

  • "(?<ChangeSummary>[^"]*)" - " char, then any zero or more chars other than a " char captured into "ChangeSummary" group, and then a " char
  • |- or
  • (?<ChangeSummary>\w+) - any one or more word chars captured into "ChangeSummary" group

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Wiktor Stribiżew