in reply to Re: Cleaning Whitespace from Source Code
in thread Cleaning Whitespace from Source Code

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