Tokenize a command string

Posted by pocoa on Stack Overflow See other posts from Stack Overflow or by pocoa
Published on 2010-04-27T16:31:22Z Indexed on 2010/04/27 16:33 UTC
Read the original article Hit count: 301

Filed under:
|

I have string like this:

command "http://www.mysite.com" some_param="string param" some_param2=50

I want to tokenize this string into:

command
"http://www.mysite.com"
some_param="string param"
some_param2=50

I know it's possible to split with spaces but these parameters can also be seperated by commas, like:

command "http://www.mysite.com", some_param="string param", some_param2=50

I tried to do it like this:

\w+\=?\"?.+\"?

but it didn't work.

© Stack Overflow or respective owner

Related posts about regex

Related posts about python