http://www.perlmonks.org?node_id=11137931


in reply to Re: solution wanted for break-on-spaces (w/specifics)
in thread solution wanted for break-on-spaces (w/specifics)

I'm not sure about this

(?:(?<!\\)\")

I read it as doublequote which is not preceded by backslash

But what about an escaped backslash \\" or two \\\\" ... ?

I'd rather try something like (Untested pseudocode)

s/^(?:$escaped|$quoted|\S)*\K\s+/\n/g

and

$escaped = qr/\\./; $quoted = qr/ (['"]) # start (?: $escaped | [^\1] )* # inside \1 # end, probably \g-1 better /x;

NB: I didn't cover the case of unclosed quotes, which is unclear anyway.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

update

tested - fails - good night! :)

update

see Re: solution wanted for break-on-spaces (w/specifics) for "working" example