如何在php中使用preg_split分割我的行?
问题描述:
I have following text
<h2>Subjects</h2>
<ul>
<li><a href='http://isbndb.com/subject/transfer_pricing'>
Transfer pricing</a></li>
<li><a
hef='http://isbndb.com/subject/intangible_property_valuation'>
Intangible property -- Valuation</a></li>
</ul>
the numbers of <li> .. </li>
could be variable.
Can anyone tell me the regex to get
Transfer pricing
Intangible property -- Valuation
it might be done with preg_split, but I have no glue how the regex should be. Thanks a lot.
我有以下文字 p>
&lt; h2&gt; Subjects&lt; / h2&gt;
&lt; ul&gt;
&lt; li&gt;&lt; a href ='http://isbndb.com/subject/transfer_pricing'>
转让定价&lt; / a&gt;&lt; / li&gt;
&lt; li&gt;&lt; a
hef ='http://isbndb.com/subject/intangible_property_valuation'>
无形财产 - 估价&lt; / a&gt;&lt; / li&gt;
&lt; / ul&gt;
code> pre>
的数量 &LT;李&GT; ..&lt; / li&gt; code>可以是变量。
任何人都可以告诉我正则表达式 p>
转移定价
无形财产 - 估价
pre>
它可能是用preg_split来完成的,但我没有胶水应该如何使用正则表达式。
谢谢你。 p>
div>
答
Try some thing like this:
$output = "<h2>Subjects</h2>
<ul>
<li><a href='http://isbndb.com/subject/transfer_pricing'>
Transfer pricing</a></li>
<li><a
hef='http://isbndb.com/subject/intangible_property_valuation'>
Intangible property -- Valuation</a></li>
</ul>";
preg_match_all("li><a href='(.[^>]*)>(.[^<]*)</",$output , $array_check);
print_r($array_check);