想不明白的PHP正則有關問題

來源:互聯網
上載者:User
想不明白的PHP正則問題
【代碼】
$str= <<HTML...




HTML...
EOD;

$reg1='/]*>(.(?!$reg2='/|[^>]+>)/s';
$reg3='/]*>(.(?!|[^>]+>)/s';

preg_match ($reg1,$str,$out1);
preg_match ($reg2,$str,$out2);
preg_match ($reg3,$str,$out3);

echo "$str\n\n\n
";
print_r($out1);
print_r($out2);
print_r($out3);



【輸出】
HTML...




HTML...



Array
(
[0] =>

[1] =>
)
Array
(
[0] =>
[1] => src="http://www.atungm.com/v/AyPzM5WK8ys" type="application/x-shockwave-flash" wmode="transparent" width="425" height="350" >
)
Array
(
)



【問題】
Regex1、Regex2分別準確完整地匹配到目標字串的前後兩部分;
Regex3是Regex1、Regex2的整合,卻出現了問題,匹配不到內容;
嘗試了好久也找不出,Regex1、Regex2之間有什麼衝突的地方?

我只有14分資源分,全部給了也就這麼多了。
不知道哪位高手能指導一下?

------解決方案--------------------
$reg3='/]*>(.(?!|[^>]+>)/s';
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.