JSFiddle - React, Tailwind, and code Playground

JavaScript

var texto = "Eu quero comprar [qtdOvós] e [qtdFrutâs] somando o total de [total Comprãs]";

var array = texto.match(/\[(?:.*?)\]/g);
for(var i in array)
{
    alert(array[i]);
}