我有很多这样的台词:
<b>http://www.mywebsite.com/video/xvxkxf_article1_something</b>
<b>http://www.mywebsite.com/video/xvxkxi_article2_something</b>
如何匹配&#34; article1_something&#34;和&#34; article2_something&#34; ?谢谢!
答案 0 :(得分:1)
答案 1 :(得分:1)
答案 2 :(得分:1)
这是一个正则表达式免费版本:
<?php
$str = "<b>http://www.mywebsite.com/video/xvxkxf_article1_something</b>";
$str = substr($str, 0, strlen($str) - 4); // removing </b>
$ar = explode("/", $str); // break url into array with / as delimiter
$ending_path = end($ar); // xvxkxf_article1_something
$ending_path_ar = explode("_", $ending_path); // break xvxkxf_article1_something with _ as delimiter
array_shift($ending_path_ar); // remove xvxkxf
$res = implode("_", $ending_path_ar); // join together pieces with _ as glue.
echo $res; // article1_something
?>
答案 3 :(得分:0)
这是你的正则表达式:
/article\d_something/