Creeper9207 Creeper9207 - 1 year ago 53
PHP Question

PHP regex to match quotes with nothing in them

Here is what i need:

"hello" "" "other"

I want this string to return (in no specific order)

[0] => "hello"
[1] => ""
[2] => "other"

Answer Source

You can do it like:


Here the captured groups will contain whatever present within the double quotes. So the first captured group will have hello, second nothing and third other.


If you need to match the quotes too: