Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: regex to split on ' ', but skip spaces inside quotes

by duff (Vicar)
on Sep 21, 2007 at 21:10 UTC ( #640440=note: print w/replies, xml ) Need Help??


in reply to regex to split on ' ', but skip spaces inside quotes

Rather than thinking in terms of "splitting on spaces", may be it would work better if you thought in terms of "gather the things I want". For instance, would this work for you:

#!/usr/bin/perl use strict; use warnings; my $string = q(hi my name is 'john doe'); my @parts = $string =~ /'.*?'|\S+/g; print map { "$_\n" } @parts; __END__
?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://640440]
help
Chatterbox?
[stevieb]: in a C++ header file, if a function declaration is listed twice with each listing containing different params, that's just essentially allowing one function accept two different arg lists, yes?

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2017-06-28 23:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (653 votes). Check out past polls.