I am trying to split a string into an array of text contents which each are present within the [@
and ]
delimiters. Just characters in between [@
and ]
are allowed to match. Being provided with a string like ...
const stringA = '[@Mary James], [@Jennifer John] and [@Johnny Lever[@Patricia Robert] are present in the meeting and [@Jerry[@Jeffery Roger] is absent.'
... the following result is expected ...
[
'Mary James',
'Jennifer John',
'Patricia Robert',
'Jeffery Roger'
]
Any logic which leads to the expected outcome can be used.
A self search for a solution brought up the following applied regex ...
stringA.match(/(?<=\[@)[^\]]*(?=\])/g);
But the result doesn't fulfill the requirements because the array features the following items ...
[
'Mary James',
'Jennifer John',
'Johnny Lever[@Patricia Robert',
'Jerry[@Jeffery Roger'
]