I believe this is what you want:
(?<=%%\[(\s|.)*)\s*(?=(\s|.)*\]%%)
https://regex101.com/r/EWhbuX/1
Edit
Here's a breakdown of the regular expression:
1.
First we start with a Positive Lookbehind (?<= )
This will make sure that the pattern that's following this, will be preceded by the pattern inside, but will not be include it in the matches.
In this case we want our matching pattern to be preceded by %%[ and any other character %%\[(\s|.)*
So, our resulting code for the Positive Lookbehind is
(?<=%%\[(\s|.)*)
2.
Next comes the pattern that we actually want to match after our Lookabehind, and (spoiler alert), before a Lookahead that we'll define later.
In this case, that's just any whitespace character, so our pattern will be
\s
(Yes, I just noticed that we don't even need the * in my original answer)
3.
Similarly to what we did at the beginning of the expression with the Lookbehind, we now need a Positive Lookahead (?= )
This is to make sure that our whitespaces will be followed by any character and ]%% (\s|.)*\]%%
.
So this is our resulting Lookahead:
(?=(\s|.)*\]%%)
4.
Put everything together and you have your regular expression!
(?<=%%\[(\s|.)*)\s(?=(\s|.)*\]%%)