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
Post a Comment