Last active
January 3, 2016 05:29
-
-
Save ruicovelo/8416652 to your computer and use it in GitHub Desktop.
The simplest way I found to parse a string accepting words separated by <space> and grouping togetther words inside quotes. Does not support nested quotes... yet...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyparsing import printable,quotedString,Word,OneOrMore | |
#text = 'words out of quotes "words inside quotes" more words out "and more words in"' | |
frase=OneOrMore(Word(printable) | quotedString) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I was using Word(alphanums) but replaced alphanums with printable because quotedString accepts all kind of crap making Word(printable) a bit more close to what quotedString accepts.