I'm writing a function that parses a nested list string that might look
like this:
( "HELLO WORLD!" 1231231 awesome ( 1 2 ) )
I wrote the logic already and it starts by splitting the string by the
space character (or tab or newline).
ex... $tklist = preg_split("/\s|\n|\t/", $str);
This works except in the string case, where "HELLO WORLD!" should not
be two parts. How do I split by spaces but keep phrases inside quotes
in tact? Is there an easy way to do this?
Thanks,
Mike
like this:
( "HELLO WORLD!" 1231231 awesome ( 1 2 ) )
I wrote the logic already and it starts by splitting the string by the
space character (or tab or newline).
ex... $tklist = preg_split("/\s|\n|\t/", $str);
This works except in the string case, where "HELLO WORLD!" should not
be two parts. How do I split by spaces but keep phrases inside quotes
in tact? Is there an easy way to do this?
Thanks,
Mike
Comment