I want to divide a string by spaces, but only if the spaces are not within square brackets.
For example:
“What a [nice sunny] day”
After dividing, it should look like this:
[What, a, [nice sunny], day]
I tried to find the solution on my own, but I’m afraid I’m not enough familiar with RegExp in javascript.
When the space has to be included, the following RegEx is needed:
In the comments, it became obvious that the spaces have to be removed: