in reply to How to Modify Only Non-Quoted Words?

$_ = q{ xxx "xxxxx xxx xxxx" 'xxxx xx xx' xxxx xxxx "xxxxx " "xxx" xxx }; s/ \G ( # $1 (?: (?:"(?:[^"\\]|\\.)*") # Skip double-quoted phrases. | (?:'(?:[^'\\]|\\.)*') # Skip single-quoted phrases. | \s # Skip whitespace. )* ) ( # $2 [^\s"']+ # Something to prefix. ) /$1A$2/gsx; print; __END__ output: ====== Axxx "xxxxx xxx xxxx" 'xxxx xx xx' Axxxx Axxxx "xxxxx " "xxx" Axxx

Replies are listed 'Best First'.
Re^2: How to Modify Only Non-Quoted Words?
by ventolin (Novice) on Aug 30, 2004 at 20:47 UTC
    Works great! Thanks!