的preg_match()从YouTube API获取数据
问题描述:
我从YouTube API的preg_match()从YouTube API获取数据
<content type='text'>
Song: Haske
Music: Atul Sharma
Lyrics: Pargat Singh
Singer: Harjeet Harman
Music On : T-Series
For latest Punjabi Music Subscribe
http://www.youtube.com/tseriesapnapunjab
http://www.facebook.com/tseriesapnapunjab
</content>
我想这些领域不与的preg_match()字段需要的歌曲:,音乐:,歌词:,歌手写一些文字:我怎样才能得到这一点(我不全部细节刚需必填项)......我是新来的preg_match(),请帮助
编辑
我是想这一点,但不没有如何得到它的工作与我的需要
$string = "/brown fox jumped [0-9]/";
$paragraph = "The brown fox jumped 1 time over the fence. The green fox did not. Then the brown fox jumped 2 times over the fence";
if (preg_match_all($string, $paragraph, &$matches)) {
foreach($matches[0] as $a){
echo $a;
}
答
这是一个尝试的正则表达式,并慢慢建立你的解决方案
你想看看preg_match_all
方法找到多个匹配的相同的字符串
这一个极好的工具将工作的例子张贴,我鼓励你弄清楚它是如何工作的
preg_match_all('/^(\w+):\s(.*?)$/m', $input, $output, PREG_SET_ORDER);
您将需要PREG_SET_ORDER通过设置将匹配组合在一起
+0
Thx ..... it works;) – Harinder 2013-05-03 14:21:47
更改'$ string =“/ brown fox jump [0-9] /”;'to'$ string =“/ brown fox jumped([0-9] )+ /“;' – reikyoushin 2013-05-03 14:14:11