If your case isn't more complex than stated in your question I'd advise you to go with
CPallini's solution
here[
^].
Just in case you'd like to know anyhow how a regular expression would look like to achieve your goal:
(.*?)(xxx|$)
This expression was verified to work with the free tool
Regular Expression Designer[
^].
It will give you four matches instead of three where the last match is the empty statement followed by the end of line. This is about the simplest regular expression I could come up with to achieve your goal.
Regards,
Manfred
P.S.: If anybody has a shorter variant please let me know. :)