In (?<=\s|^) \s is one character wide and ^ (an anchor) is 0 characters wide hence the "variable length" error.
Update: (?<=(?<=\s)|^) may work for you though.
In reply to Re^5: regexp: removing extra whitespace
by GrandFather
in thread regexp: removing extra whitespace
by perlmax
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |