Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: solution wanted for break-on-spaces (w/specifics)

by LanX (Sage)
on Oct 24, 2021 at 00:30 UTC ( #11137931=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11137931]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2022-05-24 05:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (82 votes). Check out past polls.

    Notices?