\\ in dblQuotedString

  • F.A. Pinkse

    F.A. Pinkse - 2005-05-28

    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.


    • Paul McGuire

      Paul McGuire - 2005-05-29

      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

    • F.A. Pinkse

      F.A. Pinkse - 2005-05-29

      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,



Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks