The title is so confusing, I admit it - if you want to change it you are welcome.
I'm working on PHP and preg_match function.
The problem is this string (just an example)
ON DELETE SET NULL ON UPDATE CASCADE
ON DELETE CASCADE ON UPDATE CASCADE
(another example..)
i need to find ON DELETE and ON UPDATE values, but they can't be there both.
So sometimes i have this:
ON DELETE something
and other times:
ON UPDATE something
and other times both.
So, this regex doesn't cover all possibilities:
/ON DELETE (.+) ON UPDATE (.+)/
If i put
/ON DELETE (.+)( ON UPDATE (.*))?/
-- to cover the case in which there isn't ON UPDATE
if ON UPDATE is present, first group results in "SET NULL ON UPDATE CASCADE".
How can i do that?