,比如我有以下字符串正则表达式接受字符串PHP的一部分
$s = "asd$5asd";
我怎么可以只包含在PHP之后,“d” 来了“$ 5”的一部分,我们有以下
preg_mach //returns int number of matches
preg_replace //returns the string with a replaced content
//---------------------
preg_grep //it greps but how to grep the "$5"
//that comes after "d" without grepping the "d" it's self ???
我正则表达式是
/((coupon|enter)\x20code\x20)("([^"]+)")/
我希望到grep的价值第四支架($ 4)
使用['preg_match_all('#d \ $([0-9])#',$ s,$ matches,PREG_PATTERN_ORDER]'] (http://us.php.net/preg_match)获取所有匹配。 '$ matches [1]'将包含你想要的字符串的所有实例。 – DCoder 2012-07-22 08:39:54