RegEx: Grabbing values between quotation marks

regex

Solution

I've been using the following with great success:

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

It supports nested quotes as well.

For those who want a deeper explanation of how this works, here's an explanation from user ephemient:

`([""'])` match a quote; `((?=(\\?))\2.)` if backslash exists, gobble it, and whether or not that happens, match a character; `*?` match many times (non-greedily, as to not eat the closing quote); `\1` match the same quote that was use for opening.

Problem

I have a value like this: ``` "Foo Bar" "Another Value" something else ``` What regex will return the values enclosed in the quotation marks (e.g. `Foo Bar` and `Another Value`)?

Original source

Related problems