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.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller