A space cleaner is a special character which removes all spaces between it and the first non space character to its left and it is represented by a '!' character. If it reaches the beginning of the string it stops.
Given a string output the string in any reasonable format after the cleaning process.
Trailing spaces at the end of the string must be still be in the output.
Remember that space cleaners remain after their job.
Input will only consist of printable ASCII characters.
This is code-golf, so least number of bytes win.
Test Cases
" ! a! !b c!d !" => "! a!!b c!d!"
"a !" => "a!"
"! a" => "! a"
"! ! !" => "!!!"
"! " => "! "
!
s, since it isn't quite clear. So basically, this boils down to "remove any spaces before a space cleaner", correct? \$\endgroup\$!
? This looks like it would be trivially solved by a regex looking for any number of spaces followed by a bang? \$\endgroup\$"! "
=>"! "
\$\endgroup\$