in reply to Remove Tabs and white space from a line except in Quotes
Here's a slightly different approach. I don;t how it works out for efficiency, but it doesn't require any backtracking.
$_ ='the quick "brown fox" jumps over the "lazy dog"'; $in = 0; s[ (?>(.)) (?{ $in = ~ $in if $1 eq '"' }) ([\t ]) ] [ $in ? $1.$2 : $1 ]gex; print thequick"brown fox"jumpsoverthe"lazy dog"
You didn't specify whether you wanted the quotes removed , so I left them in.
|
|---|