我希望正则表达式只用tweet id替换。我试过下面的正则表达式,但不起作用。
$string = "The meeting, which was also attended by Chief Bisi Akande, held at the Abuja House in London, a tweet from the presidency revealed.
[twt]https://twitter.com/NGRPresident/status/829704039952740352[/twt]
[twt]https://mobile.twitter.com/NGRPresident/status/829713387001114625[/twt]
President Buhari has been away from Nigeria since January when he departed for a 10-day medical vacation.";
$regex = '/\[twt\]\/https?://twitter\.com/(?:\#!/)?(\w+)/status(es)?/(\d+)[\/twt\]/';
$string = preg_replace("$regex", '$3', $string);
echo $string;'
我希望结果输出;
总统会议的推文显示,此次会议由总理比西·阿坎德出席,在伦敦阿布贾众议院举行。
829704039952740352
829713387001114625
布哈里总统自1月份离开尼日利亚后,离开了10天的医疗假期。答案 0 :(得分:0)