RegEx: Grabbing values between quotation marks

前端 未结 20 1233
暖寄归人
暖寄归人 2020-11-22 02:13

I have a value like this:

\"Foo Bar\" \"Another Value\" something else

What regex will return the

20条回答
  •  名媛妹妹
    2020-11-22 02:45

    From Greg H. I was able to create this regex to suit my needs.

    I needed to match a specific value that was qualified by being inside quotes. It must be a full match, no partial matching could should trigger a hit

    e.g. "test" could not match for "test2".

    reg = r"""(['"])(%s)\1"""
    if re.search(reg%(needle), haystack, re.IGNORECASE):
        print "winning..."
    

    Hunter

提交回复
热议问题