preg_replace 第一个双引号之前和第二个双引号之后的所有内容
preg_replace everything before the first and after the second double quotes
找不到任何有用的东西。需要删除第一个和第二个双引号之前的所有内容:
示例:
<a href="http://somesite.com"><img src="http://somesite.com/image.png"></a>
结果应该是:
http://somesite.com
非常感谢!
已解决:请参阅@ankabout 的解决方案。
$html = '<a href="http://somesite.com"><img src="http://somesite.com/image.png"></a>';
$dom = new DOMDocument();
$dom->loadHTML($html);
var_dump($dom->getElementsByTagName('a')[0]->getAttribute('href'));
我想你需要的是这样的东西。
<?php
$input = '<a href="http://somesite.com"><img src="http://somesite.com/image.png"></a>';
$parse = '<a href=\x22(.+?)\x22>' ;
preg_match_all($parse, $input, $out, PREG_PATTERN_ORDER);
echo $out[1][0];
找不到任何有用的东西。需要删除第一个和第二个双引号之前的所有内容:
示例:
<a href="http://somesite.com"><img src="http://somesite.com/image.png"></a>
结果应该是:
http://somesite.com
非常感谢!
已解决:请参阅@ankabout 的解决方案。
$html = '<a href="http://somesite.com"><img src="http://somesite.com/image.png"></a>';
$dom = new DOMDocument();
$dom->loadHTML($html);
var_dump($dom->getElementsByTagName('a')[0]->getAttribute('href'));
我想你需要的是这样的东西。
<?php
$input = '<a href="http://somesite.com"><img src="http://somesite.com/image.png"></a>';
$parse = '<a href=\x22(.+?)\x22>' ;
preg_match_all($parse, $input, $out, PREG_PATTERN_ORDER);
echo $out[1][0];