Why keep it simple when you can make it complicated? (French expression ;-)
My goal was to avoid automatic line breaks between a word and a punctuation mark.
I just thought it would be much simpler to replace the space with
!
So I do this for the punctuation marks at the end:
[ ]+([\?\:!€"»;\)\]}])
Replace by $1
And this for the punctuation marks at the beginning:
(["«\(\[{])[ ]+([\w])
Replace by $1 $2
I think that will be enough.