I would like to create an Array out of this string:
// string
'a b[text="Fly to San Fran",text2="More"] c foo[text=Fly to San Fran,text2=More] bar d'
// resulting array:
[
'a',
'b[t="Fly to San Fran",text2=More]',
'c',
'foo[t=Fly to San Fran,text2=More]',
'bar',
'd'
]
How would a regex look like to split the string or is this the wrong approach?
So far I tried the following, which results in way too many null values.
/([a-zA-Z]*\[[a-z]*\])|([\w]*)/g
=>
[
'a',
null,
'b[t="Fly to San Fran",text2=More]',
null,
'c',
null
'foo',
null,
[t=Fly to San Fran,text2=More]',
null,
'bar',
null,
'd'
]