So, I've inherited this beast of a PowerApp that does something relatively simple, collects responses to dynamic quizzes created in the app. The operator creates questions (which adds items to a SPO list) and then sends the quiz out to folks who then go and answer it in the PowerApp.
Because the questions are created more or less on a whim and because PowerApps can't create new data sources on the fly or manipulate the data sources it uses, instead of having a column for every question/answer pair, those QnA pairs are concatenated into a giant blob of plain text and shoved into a single column in a separate SPO list holding response in the format:
Question: Question1 Text? Answer: Answer1 Text | Question: Question2 Text? Answer: Answer2 Text, etc., etc.
I've figured out the regex I need to split the block into QnA pairs (split on the bar character) and then each QnA pair into, essentially, a 2D array (in JavaScript, anyway, I'd split on the regex /((\?|\.)( Answer: ))/
because of course a question can end on either a period or a question mark).
What I can't quite figure out because PowerApps' function engine is bizarre and byzantine, is how to use that regex to turn that blob into a table I can output into the app so my operator can extract the data into something more useful.
Edit 1:
Getting a little closer. With the following function I can get a 2D collection:
ClearCollect(
QnAPairs,
ForAll(
'ResponsesList',
Split(
'ResponsesList'[@Answers],
"|"
)
)
);
Still at a loss on how to treat each result in the QnA collection like key/value pairs I can add to a fresh table.
TL;DR?
How to turn
Name | Date | Answers Person McPerson | mm/dd/yy | Question: Question1 Text? Answer: Answer1 Text | Question: Question2 Text? Answer: Answer2 Text, etc., etc.
Into
Name | Date | Question1 Text | Question2 Text | ...QuestionN Text Person McPerson | mm/dd/yy | Answer1 Text | Answer2 Text | ...Answer2 Text