php - Regex - escaping ' -


i'm trying parse string , extract values.

suddenly, i'm stuck with symbols here:

here code, describe situation:

// example string $string = "@set('var', 'value')";  // regex i'm using extract values $regex = '@set\((.+),(.+)\)/'  // result i'm getting array("'var'", "'value'")  // desired result array("var", "value") 

any ideas?

you matching character .+ rule. if don't want quotes in result, avoid them. rewrited rule:

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

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -