RegEx: Grabbing values between quotation marks

前端 未结 20 1692
暖寄归人
暖寄归人 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:40

    The RegEx of accepted answer returns the values including their sourrounding quotation marks: "Foo Bar" and "Another Value" as matches.

    Here are RegEx which return only the values between quotation marks (as the questioner was asking for):

    Double quotes only (use value of capture group #1):

    "(.*?[^\\])"

    Single quotes only (use value of capture group #1):

    '(.*?[^\\])'

    Both (use value of capture group #2):

    (["'])(.*?[^\\])\1

    -

    All support escaped and nested quotes.

提交回复
热议问题