In article <3f19e4c0-e010-4cb2-9f71-dd09e0d3c...@r9g2000vbw.googlegroups.com>, Massi says... > >Hi everyone, > >I have to parse a string and splitting it by spaces. The problem is >that the string can include substrings comprises by quotations which >must mantain the spaces. What I need is to pass from a string like: > >This is an 'example string' > >to the following vector: > >["This", "is", "an", "example string"] > >Which is the best way to achieve this? >Thanks in advance!
Is this what you want? import shlex lText = "This is a 'short string' for you to read." lWords = shlex.split(lText) print lWords produces, ['This', 'is', 'a', 'short string', 'for', 'you', 'to', 'read.'] Shlex can be found under 'Program Frameworks' under 'The Python Standard Library' of ActivePython 2.7 documentation. C:\Source\Python\New> -- http://mail.python.org/mailman/listinfo/python-list