Re: split string saving screened spaces

2005-12-16 Thread Paul McGuire
Pyparsing has built-in quoted string support. from pyparsing import OneOrMore,Word,alphanums,quotedString item = Word('-',alphanums) | quotedString | Word(alphanums) items = OneOrMore(item) print items.parseString( "-a -b -c '1 2 3' -d 5 -e zork2000" ) gives: ['-a', '-b', '-c', "'1 2 3'", '-d'

Re: split string saving screened spaces

2005-12-16 Thread bonono
Sergey wrote: > Which module to use to do such thing: > > "-a -b -c '1 2 3'" -> ["-a", "-b", "-c", "'1 2 3'"] > > (i have string, need to pass it to getopt) seems like CSV except that the seperator is space. You may check to see if the CSV module can take space as delimiter. -- http://mail.pytho

Re: split string saving screened spaces

2005-12-16 Thread Giovanni Bajo
Sergey wrote: > Which module to use to do such thing: > "-a -b -c '1 2 3'" -> ["-a", "-b", "-c", "'1 2 3'"] >>> import shlex >>> shlex.split("-a -b -c '1 2 3'") ['-a', '-b', '-c', '1 2 3'] -- Giovanni Bajo -- http://mail.python.org/mailman/listinfo/python-list