orwhile (s/\s*$RE$//) {}
will get you there without leaving trailing spaces in the finished $_. (Update: made it a little easier to read.)s/(\s*$RE)*$//;
In reply to Re: regexp - repeatedly delete words from end of string with words in alternation
by gamache
in thread repeatedly delete words expressed in alternation from end of string [regexp]
by princepawn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |