Looking for a way to match the fourth element in this expression:
var string = [a][1] [b][2] [c][3] [d .-][] [e][4]
The element we're trying to target is [d .-][]
. This specific element can contain any character within the first set of brackets, while the second set remains empty. Other elements like [a][1]
can contain any character but must have a number inside their second set of brackets.
I attempted using this regex pattern:
string.match(/\\[[^]+]\\[ ]/);
However, it proved to be too greedy in its matching.
If you have any suggestions or solutions, I would greatly appreciate your help.