I have the following string:
group:[random text]_updated_at
and I'm trying to extract the text inside the brackets []. Basically I want to print out this text:
random text
I've tried using split function
let arr = str.split('[')[1];
console.log(arr); // random text]_updated_at
but I believe it could better using regex? Does anyone know how I can print the text using regex?
NOTE:
- I don't want to use substring because the text within the brackets could potentially change.
- The text group: will always be there in the beginning.