I have a text with string content and a tag. I want to split the text into an array. I tried many ways but got some bugs @@
Input:
"This is a text with a @[name of tag](tagId). This is another @[name of another tag](tagId)"
Output:
array = ["This is a text with a ", "@[name of tag](tagId)", ". This is another " , "@[name of another tag](tagId)"]
The tag always has @[ at begin, ) at the end and ]( at between,
I tried
const str = "This is a text with a @[name of tag](tagId). This is another @[name of another tag](tagId)"
const result = str.split(/[@[)]/);
console.log(result);
But that has many issues like "", " " or missing @[ in result
Thanks for all help