From all the parsing packages I have used so far pyparsing gave me result straight away even with not all the possiblilties explored.
But... what do I need to do to get a '\' parsed as part of the text between " and " like in:
"G:\\Folder name\\filename.extension"
dblQuotedString does not handle the \\. to be more precise it stops parsing at the position of \, with an error Expected '"' when
I used dblQuotedString.setDebug()
With best regards.
Frans.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi All,
From all the parsing packages I have used so far pyparsing gave me result straight away even with not all the possiblilties explored.
But... what do I need to do to get a '\' parsed as part of the text between " and " like in:
"G:\\Folder name\\filename.extension"
dblQuotedString does not handle the \\. to be more precise it stops parsing at the position of \, with an error Expected '"' when
I used dblQuotedString.setDebug()
With best regards.
Frans.
Frans -
You may wish to create your own special quoted string definition for this case. Here is a very simple-minded one:
from pyparsing import *
test = r'Here is a quoted filespec: "G:\Folder name\filename.extension" '
QUOTE = Literal('"').suppress()
quotedFilespec = Combine( QUOTE + CharsNotIn('"\n\r') + QUOTE )
for t,s,e in quotedFilespec.scanString(test):
print t[0]
This quotedFilespec will not do any special handling of backslashes, so it will work well for you for quoted strings that contain Windows filespecs.
-- Paul
Hi Paul,
Ok, working around is good. I was focussed on options in the dblQuotedString.
Thank you for the example. It worked for me.
Great package.
With best regards,
Frans.