gpt4 book ai didi

HTML 标签上的 PHP preg_match()

转载 作者:行者123 更新时间:2023-11-27 22:34:01 26 4
gpt4 key购买 nike

<分区>

我正在尝试使用 preg_match() 检索 to。

我写过:

<?php
$file=file_get_contents('Temp.txt');
$regexp='<div class\=\"cropped-image\" style\=\"width:102px;height:102px;\">(.*)
</div>';
preg_match($regexp,$file,$string1);
echo $string1[0];
?>

输入:

<table class="search-results" data-search-total="5068" data-search-type="artists" data-search-term="taylor" data-search-genre="all">
<tr class="search-result artist">
<td>

<div class="image">
<div class="thumbnail sm artist">
<a href="/artist/taylor-swift-mn0000472102" data-tooltip="{&quot;id&quot;:&quot;MN0000472102&quot;,&quot;thumbnail&quot;:true,&quot;position&quot;:{&quot;my&quot;:&quot;left center&quot;,&quot;at&quot;:&quot;middle right&quot;}}">
<div class="cropped-image" style="width:102px;height:102px;" ><img src="http://cps-static.rovicorp.com/3/JPG_170/MI0003/436/MI0003436897.jpg?partner=allrovi.com" style="left:-25px" width="153" height="102" alt="Taylor Swift" data-debug="170x113 (63)"></div> </a>
</div>
</div>
<div class="right-of-image">
<div class="type">
<span class="sprite2 icon-search-artist-new" title="artist"></span>
</div>
<div class="name">
<a href="http://www.allmusic.com/artist/taylor-swift-mn0000472102" data-tooltip="{&quot;id&quot;:&quot;MN0000472102&quot;,&quot;thumbnail&quot;:true,&quot;position&quot;:{&quot;my&quot;:&quot;left center&quot;,&quot;at&quot;:&quot;middle right&quot;}}">Taylor Swift</a> </div>

<div class="info">
Country, Pop/Rock
<br/>

2000s - 2010s
</div>

</div>

</td>

我得到的错误是:警告:preg_match(): TrialPHP.php 中第 4 行的未知修饰符 '('。我也在特殊字符前包含了\。

我试过 DOM parser它运行成功。但我必须使用正则表达式进行分配。我该怎么办??

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com