in typescript "$groupcontributors" regex this so I get contributors and pid in array
- User
in typescript "$groupcontributors" regex this so I get contributors and pid in array
Assistant
You can use a regex with capturing groups to extract both parts:
const input = "$group[contributors](pid)"; const regex = /\$group\[([^\]]+)\]\(([^)]+)\)/; const match = input.match(regex); if (match) { const [, contributors, pid] = match; const result = [contributors, pid]; console.log(result); // ["contributors", "pid"] }Or if you want to handle multiple matches in a string:
const input = "$group[contributors](pid) and $group[users](123)"; const regex = /\$group\[([^\]]+)\]\(([^)]+)\)/g; const matches = [...input.matchAll(regex)]; const results = matches.map(match => [match[1], match[2]]); console.log(results); // [["contributors", "pid"], ["users", "123"]]The regex breakdown:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.