, . . .
The module regexsupports access to all previous matches of the capture group , which is necessary for the following actions:
>>> import regex
>>>
>>> pattern = r'(?V0)[{] (?P<u>\s+)? (?: (?: [^\s}]+ (?P<u>\s+) )* [^\s}]+ (?P<u>\s+)? )? [}]'
>>> string = 'abc and 123 {foo-bar bar baz } bit {yummi tummie} byte.'
>>> [s for m in regex.finditer(pattern, string, regex.VERBOSE) for s in m.captures('u')]
[' ', ' ', ' ', ' ']
Simply put, this regular expression finds matches in the form '{' blanks? ((nonblanks blanks)* nonblanks blanks?)? '}'and assigns all the empty parts to the same capture group with the name u( (?P<u>...)).
It also works with strings containing unsurpassed {and }:
>>>
>>> badstring = '}oo} { ab a b}} xy {xy x y}cd {{ cd } e{e }f{ f} { }{} }{'
>>>
>>> [s for m in regex.finditer(pattern, badstring, regex.VERBOSE) for s in m.captures('u')]
[' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ']
>>>
>>> [v for m in regex.finditer(pattern, badstring, regex.VERBOSE) for v in m.capturesdict().values()]
[[' ', ' ', ' '], [' ', ' '], [' ', ' '], [' '], [' '], [' '], []]
Tested on Python 3.5.1 x64, regex 2016.3.2.