I have the following string.
MUST (key1=value1)(key2>value2)NOT (key3=value3) SHOULD (key4=value4)
And I need to split it into three strings.
MUST(key1=value1)(key2>value2)
NOT(key3=value3)
SHOULD(key4=value4)
Some statements, for example, NOT or SHOULD could be absent. So, I must match the end of the line also.
For now, I came up with a regex like this /(MUST)?.*(?=NOT)/
But it doesn't work if SHOULD is before NOT or there is only MUST. How can I add OR operator here, something like (?=NOT|SHOULD|$)