I had a problem splitting text using a square bracket in an array. If there is no text in the square bracket, then it will not catch. The code is in JavaScript, as shown below:
var text = 'This note is created on [date] by [admin;operator] for []'
var myArray = text.match(/\[([^[]+)\]/g);
console.log(myArray);
and result
["[date]", "[admin;operator]"]
but I want
["[date]", "[admin;operator]", []]
How to improve my template to get an empty square bracket ([])?
source
share