foobar1977 has asked for the wisdom of the Perl Monks concerning the following question:
Hey Peeps
After a little guidance on the most effective way to split a string based on multiple delimiters.
For the most part, splitting on space would suffice however, the input also allows for quoted stuff, which could/will contain spaces.
Essentially it is a space separated list of commands, however any of those commands taking arguments must be wrapped in double quotes.
'command1 command2 command3 "command4 --some-arg arg --some-other-arg 2" command5'
I'm struggling to see the most efficient way to split this into an array without jumping though hoops and I know there must be a way to do it.
Any pointers greatly appreciated :)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: splitting on multiple delimiters
by toolic (Bishop) on Jun 09, 2008 at 17:14 UTC | |
|
Re: splitting on multiple delimiters
by moritz (Cardinal) on Jun 09, 2008 at 17:00 UTC | |
|
Re: splitting on multiple delimiters
by johngg (Canon) on Jun 09, 2008 at 21:14 UTC | |
|
Re: splitting on multiple delimiters
by BrowserUk (Patriarch) on Jun 09, 2008 at 18:15 UTC | |
|
Re: splitting on multiple delimiters
by punch_card_don (Curate) on Jun 09, 2008 at 19:48 UTC | |
|
Re: splitting on multiple delimiters
by GrandFather (Saint) on Jun 09, 2008 at 23:59 UTC | |
|
Re: splitting on multiple delimiters (2 ways)
by tye (Sage) on Jun 10, 2008 at 06:48 UTC | |
|
Re: splitting on multiple delimiters
by foobar1977 (Novice) on Jun 10, 2008 at 08:00 UTC |