I have bash script I only want to support long options ("--option"). An --option can optionally have one or more arguments. All words (anything delimited by whitespace) up to but not including the first '--' OR the end of the command line string are considered "--option-arguments". A trailing space in the result is okay. Maximum performance is desired since this function is called by other functions for each possible option. Thus, trying to avoid bash loops and external commands.
Fought for many hours with the "first occurrence" issue until I found this answer that reminded me that POSIX (and thus bash) does not support nongreedy/lazy regex operators.
What to do?