in reply to Regex doesn't wanna find the spaces :/

You can use look-around assertions to avoid the need for captures. You might want to anchor the assertions to the start and end of the string depending on your data.

$string =~ s{(?: (?<===) \s+ | \s+ (?===) )}{}gx;

I hope this is of interest.

Cheers,

JohnGG