(inputStr: string)
| 37 | }; |
| 38 | |
| 39 | export const extractArray = (inputStr: string): string[] => { |
| 40 | // Match an outer array of strings (including nested arrays) |
| 41 | const regex = |
| 42 | /(\[(?:\s*(?:"(?:[^"\\]|\\.|\n)*"|'(?:[^'\\]|\\.|\n)*')\s*,?)+\s*\])/; |
| 43 | const match = inputStr.match(regex); |
| 44 | |
| 45 | if (match && match[0]) { |
| 46 | try { |
| 47 | // Parse the matched string to get the array |
| 48 | return JSON.parse(match[0]) as string[]; |
| 49 | } catch (error) { |
| 50 | console.error("Error parsing the matched array:", error); |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | console.warn("Error, could not extract array from inputString:", inputStr); |
| 55 | return []; |
| 56 | }; |
| 57 | |
| 58 | // Model will return tasks such as "No tasks added". We should filter these |
| 59 | export const realTasksFilter = (input: string): boolean => { |
no outgoing calls
no test coverage detected