Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
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 rifling through the Monastery: (3)
As of 2023-02-03 22:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (30 votes). Check out past polls.

    Notices?