本文目录一览:
- 1、php正则,提取视频地址
- 2、php正则表达式,在record.txt中有以下内容,如果已知aaa.mp4,想要提取aaa.mp4整行,求帮忙!
- 3、用PHP获取链接及图片路径的方法
- 4、php 正则 提取 include或者include_once
- 5、用PHP提取出某网页的视频地址
- 6、php用正则表达式提取img的路径
php正则,提取视频地址
改成这样
'/(src|width|height)=([\"|\'])?(.*?)(?(2)\2|\s)/is'
上例子会明白的
?php
$html = 'EMBED style="WIDTH: 643px; HEIGHT: 514px" height=514 type=application/x-shockwave-flash align=middle width=643 src=视频地址v.swf allowFullscreen="true" allowScriptAccess="sameDomain" quality="high"/EMBED';-php正则提取mp4路径
$search = '/(src|width|height)=([\"|\'])?(.*?)(?(2)\2|\s)/is';
preg_match_all($search, $html , $r);
echo 'pre';
print_r($r);
echo '/pre';
?
php正则表达式,在record.txt中有以下内容,如果已知aaa.mp4,想要提取aaa.mp4整行,求帮忙!
这里是xml啊
建议不要用正则表达式,用xml parser不是更准确么?
用PHP获取链接及图片路径的方法
?php
$str = "This is a test.This is a test.This is a a href=;img src= //atest.This is a test.This is a test.\n" .-php正则提取mp4路径
"This is a test.This is a test.a href=;img src= //aThis is a test.This is a test.This is a test.\n" .-php正则提取mp4路径
"a href=;img src= //a";
$regex = '/a\s+href=(.*)\s*img\s+src=(.*)\s*\/\/a/';
$output = array();
if (preg_match_all($regex, $str, $matches) !== false) {
if (isset($matches[1]) isset($matches[2])) {
$links = $matches[1];
$imgs = $matches[2];
foreach ($links as $key = $link) {
$img = isset($imgs[$key]) ? $imgs[$key] : '';
$output[] = "a href=\"{$link}\"img src=\"{$img}\" //a";
}
}
}
var_dump($output);
php 正则 提取 include或者include_once
?php
$str = "include('../../inc1.php');
include '../../inc2.php';
include_once('../../inc3.php');
include_once '../../inc4.php';";
$pa = '/include(_once)? ?\(? ?\'(.*?)\'\)?/si';
preg_match_all($pa,$str,$r);
echo '共引入以下文件:br/';
for($i=0;$icount($r[2]);$i++)
{
echo $r[2][$i]."br /\r\n";
}
?
用PHP提取出某网页的视频地址
比如这个文件我们存为 test.php,那么我们只需要运行 test.php?优酷视频的url 就可以解析出FLASH地址了。
php用正则表达式提取img的路径
$url = 'aonews.com/upload/news/201505/20150531152540501467.jpg';
preg_match('/\/upload\/news\/\d+\//', $url, $match);
echo $match[0];///upload/news/201505/