Parser, smarser. Just use a simple regex. As a start:
s{ ( # $1 for whole match ' (?: \\. | [^']+ )* ' # 'string' | " (?: \\. | [^"]+ )* " # "string" | (?:^|\r*\n)[^\S\n]* # leading spaces | ([^\S\n]+) # $2 is trivial spaces ) }{ $2 ? ' ' : $1 }gsex
- tye
In reply to Re^2: Cleaning Whitespace from Source Code (re)
by tye
in thread Cleaning Whitespace from Source Code
by hackdaddy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |