I would like to parse the following string:
this OR (this AND (this OR (that AND this))) OR this
Into this:
[
"this",
"OR",
[
"this",
"AND",
[
"this",
"OR",
[
"that",
"AND",
"this"
]
]
],
"OR",
"this"
]
However, I also need to support things like "this is a text" OR this
which parses as ["this is a text", "OR", "this"]
where the quotes represent the whole string which cancels the space-breaking between words.
But this is not an issue since it's not recursive like brackets, this can be done with regex.
After some research, this can not be done with ES regex, but can be done with PHP's regex. Is there a way to do it with javascript's regex? If not, what are the best alternatives to use, maybe a pre-built library for this?