In article <[email protected]>, 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
