RegEx: Grabbing values between quotation marks

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

    Unlike Adam's answer, I have a simple but worked one:

    (["'])(?:\\\1|.)*?\1
    

    And just add parenthesis if you want to get content in quotes like this:

    (["'])((?:\\\1|.)*?)\1
    

    Then $1 matches quote char and $2 matches content string.

提交回复
热议问题