Suppose the given string is:
[[1]] is for cars, as [[2]] is for bikes
I want to split the string into an array of string using regex or any other way, when [[any number]] (for example: [[1]], [[2]]) is encountered.
[
[[1]],
" is for cars, as ",
[[2]],
" is for bikes"
]
What I have tried:
"[[1]] is for cars, as [[2]] is for bikes".split(/\[\[(\d+)\]\]/gi);
This returns ",1, is for cars, as ,2, is for bikes"