[Solved] Javascript string.match with specific prefix and text after [closed]


You can use /specialPrefix:\s*(\[.*?\])/

let inputs = ["any string before specialPrefix: ['content1', 'content2'] and any other text after","any string before specialPrefix:['content1', 'content2'] and any other text after","any string before specialPrefix: 'content1', 'content2' and any other text after"];  
var result = inputs.map(str => (/specialPrefix:\s*(\[.*?\])/.exec(str) || [])[1]);
console.log(result);

solved Javascript string.match with specific prefix and text after [closed]