正则表达式 - 逃避'

I'm trying to parse a string and extract some values.

Suddenly, I'm stuck with the with symbols here:

Here is some code, to describe my situation:

// example string
$string = "@set('var', 'value')";

// regex that I'm using to extract the values
$regex = '@set\((.+),(.+)\)/'

// result that I'm getting
array("'var'", "'value'")

// desired result
array("var", "value")

Any ideas?

You are matching any character with .+ rule. If you don't want quotes to be in the result, avoid them. Rewrited rule:

 $regex = "/@set\('([^']+)',\s*'([^']+)'\)/"