1
我有动态字符串是这样的:PHP:Preg_match_all逃脱圆括号
$string1 = '<a style="background-image: url("http://someurl.com/image.jpg");" class="thumb" title="title goes here" href="http://www.someurl.com/"></a>';
我preg_match_all代码:
preg_match('/<a style="background-image: url((.*?));" class="thumb" title="(.*?)" href="(.*?)"><\/a>/', $string1, $matches);
echo $matches['1'];
echo $matches['2'];
echo $matches['3'];
的网址()括号不工作,任何想法如何逃脱?
'\\'是典型的转义字符。 – Jon 2013-04-06 13:18:27
[括号中的PHP正则表达式]可能的重复(http://stackoverflow.com/questions/8220180/php-regex-with-parentheses) – mario 2013-04-06 13:19:59