You could explicitly make a regex for each case (the first will capture two), utilizing beginning and end of line tokens
(^hi( everyone)?$)
(^everyone hi$)
I can't figure out how to write regex that matches these:

everyone hi
hi everyone
hi

But not this:

everyone hi everyone

The regex (?:everyone )?hi(?: everyone)? will match the latter as well (which is not what I want). How to make such a regex? Or is it just not possible? I couldn't do enough research because I couldn't express the problem in correct words. Sorry if I posted a duplicate
Regex match no groups, 1st group OR 2nd group but not both. Something like 'NAND'