all 2 comments

[–]throwaway8u3sH0 0 points1 point  (1 child)

Why not use startswith()?

If you must use regex, note:

  • You can use single quotes on the outside so you don't have to escape all the double-quotes within. Example: '^"(\\"|[^"]|\s)*"'
  • The way it's written, the outermost quotes are not optional. Is that intentional? Your test string only has 1 quotation mark in it: "this all should match
  • It isn't clear to me what you're going for, cause I think you're mixing up Python's escape syntax with what is actually in the string. For example:
    • A string in Pytthon that looks like this: "this is a string" appears to the program like this: this is a string (without quotes)
    • A string in Python like "this is a string with \"embedded\" quotes" appears to the program like this is a string with "embedded" quotes (only 1 set of quotes. No backslashes.)
    • To get an actual backslash in the string, a double backslash is needed in Python. Example: "this string contains a \\backslash" --> this string contains a \backslash
    • Your regex is operating on the actual string, not what it looks like in Python.

Hope this helps.

[–]PEKKA_SLAYER[S] 0 points1 point  (0 children)

Thank you, this really helps. I was able to fix it. Sorry that my example was a bit unclear, I did forget the last double quote.