DDR爱好者之家 Design By 杰米
html代码
复制代码 代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
{t:arc row='10'}
{t:field.title/}
{t:list row='5'}
{t:field.title/}
{t:list row='5'}
{t:field.title/}
{/t:list}{t:field.title/}
{/t:list}{t:field.title/}
{/t:arc}
{T:channelartlist
row='6'
}
<dl>
<dt>{t:field name='typename'/}{t:field.typename/}</dt>
<dd>
{t:arclist titlelen='42' row='10'}
<ul class='autod'>
<li>[field:title/]</li>
<li>([field:sendtime function="MyDate('m-d',@me)"/])</li>
</ul>
{/t:arclist}
</dl>{/t:channelartlist
}
{t:global.cfg_title
/}{t:var.cfg_title/}{t:global.cfg_webname /}{t:global.cfg_title/}{t:var.cfg_title/}
{t:field.title function="Html2Text(@me)"/}
{t:include
filename="header.htm"/}
{t:include filename="header.htm"
/}
{t:field.title function='Html2Text(@me)' }{/t:field
}
{t:array name='asdas' }{/t:array
}
{t:channel typeid='1' row='15'}
[field:id/][field:typename/]
{/t:channel
}
{t:channel typeid='1'} [field:id/] [field:typename/]{/t:channel}
{t:channel typeid='1' }[field:id/]
[field:typename/]{/t:channel
}sd
{t:channel}[field:typename/]{/t:channel
}
{t:channel typeid='1' row='20' }[field:userid/]
[field:scores/]
{/t:channel
}
</body>
</html>
php代码
复制代码 代码如下:
<?php
$str = file_get_contents("test.htm");
$skstr="{";
$skdstr="t:";
$sdstr="}";
//$reg="/{t:.*?(?:\/).*?}/si";//此无法匹配嵌套,只能一层 si s: 使前面的. 包括换行符 i:不区分大小写
//$reg="/({t:*[^{]*\/}|{t:*[^}]*}([^{]|(?R))*{\/t:.*?})/si";无限嵌套都可截取.
$reg='/('.$skstr.$skdstr.'*[^'.$skstr.']*\/'.$sdstr.'|'.$skstr.$skdstr.'*[^'.$sdstr.']*'.$sdstr.'([^'.$skstr.']|(?R))*'.$skstr.'\/'.$skdstr.'.*?'.$sdstr.')/si';
preg_match_all($reg,$str,$m);
/*echo "<pre>";print_r($m[0]);echo "</pre>";exit();*/
$CTags=array();
$glarr1=array($skstr.$skdstr=>'');//array('{t:'=>'');前缀
$glarr2=array('"'=>'','\''=>'','$'=>'','/'=>'');
/*
{t:array typeid='1'}[field:typename/]{/t:array}
{t:global.title function="html2text(@me)"/}
*/
foreach($m[0] as $k=>$v){
$rarr=array();
$rarr['str']=$v; //原模板字符串
$vs=explode('}',$v); //分割取得第一部分 {t:array typeid='1'
$va=explode(' ',$vs[0]); //分割属性 " {t:array " , " typeid='1' "
$vb=explode('.',$va[0]); //分割标签名和字段名 {t:global.title
$rarr['tagname']=trim(strtr(strtolower($vb[0]),$glarr1));//过滤前缀{t: 取得标签名 array 或 golbal
$rarr['tagfield']=strtr($vb[1],$glarr2); //取得字段名 title
unset($vs[0]);$vsstr=implode('}',$vs); //去掉前缀,返回后半段: [field:typename/]{/t:array}
$rarr['text']=preg_replace("/".$skstr."\/".$skdstr.$rarr['tagname']."(.*?)".$sdstr."/si",'',$vsstr);
/*过滤后缀 {/t:array} 取得中间文本.
可能出现,空格或者换行所以使用正则,也可直接使用strtr 替换 。
{/t:array }
{/t:array
}
strtr(strtolower($vsstr),array($skstr.'/'.$skdstr.$rarr['tagname'].$sdstr=>''));
*/
unset($va[0]);
$attr=array();
foreach($va as $val){//循环记录属性
$val=strtr($val,$glarr2); //typeid='1' 去掉 " ' / , typeid=1
$vc=explode('=',$val);
if(!empty($vc[0])){
$vc[0]=strtolower($vc[0]); //小写属性名
if($vc[0]=="function"){
$rarr['function']=$vc[1]; //返回要执行的 html2text(@me)
}else if($vc[0]=="name"){
$rarr['tagfield']=$vc[1]; //{t:field name='title' /}
}else{
$attr[trim($vc[0])]=$vc[1]; //属性 $attr['typeid']=1;
}
}
}
$rarr['attr']=$attr;
$CTags[$k]=$rarr;
}
echo "<pre>";
print_r($CTags);
echo "</pre>";
?>
输出内容:
复制代码 代码如下:
Array
(
[0] => Array
(
[str] => {t:arc row='10'}
{t:field.title/}
{t:list row='5'}
{t:field.title/}
{t:list row='5'}
{t:field.title/}
{/t:list}{t:field.title/}
{/t:list}{t:field.title/}
{/t:arc}
[tagname] => arc
[tagfield] =>
[text] =>
{t:field.title/}
{t:list row='5'}
{t:field.title/}
{t:list row='5'}
{t:field.title/}
{/t:list}{t:field.title/}
{/t:list}{t:field.title/}
[attr] => Array
(
[row] => 10
)
)
[1] => Array
(
[str] => {T:channelartlist
row='6'
}
{t:field name='typename'/}{t:field.typename/}
{t:arclist titlelen='42' row='10'}
[field:title/]
([field:sendtime function="MyDate('m-d',@me)"/])
{/t:arclist}
{/t:channelartlist
}
[tagname] => channelartlist
[tagfield] =>
[text] =>
{t:field name='typename'/}{t:field.typename/}
{t:arclist titlelen='42' row='10'}
[field:title/]
([field:sendtime function="MyDate('m-d',@me)"/])
{/t:arclist}
[attr] => Array
(
[row] => 6
)
)
[2] => Array
(
[str] => {t:global.cfg_title
/}
[tagname] => global
[tagfield] => cfg_title
[text] =>
[attr] => Array
(
)
)
[3] => Array
(
[str] => {t:var.cfg_title/}
[tagname] => var
[tagfield] => cfg_title
[text] =>
[attr] => Array
(
)
)
[4] => Array
(
[str] => {t:global.cfg_webname /}
[tagname] => global
[tagfield] => cfg_webname
[text] =>
[attr] => Array
(
)
)
[5] => Array
(
[str] => {t:global.cfg_title/}
[tagname] => global
[tagfield] => cfg_title
[text] =>
[attr] => Array
(
)
)
[6] => Array
(
[str] => {t:var.cfg_title/}
[tagname] => var
[tagfield] => cfg_title
[text] =>
[attr] => Array
(
)
)
[7] => Array
(
[str] => {t:field.title function="Html2Text(@me)"/}
[tagname] => field
[tagfield] => title
[text] =>
[function] => Html2Text(@me)
[attr] => Array
(
)
)
[8] => Array
(
[str] => {t:include
filename="header.htm"/}
[tagname] => include
[tagfield] =>
[text] =>
[attr] => Array
(
[filename] => header.htm
)
)
[9] => Array
(
[str] => {t:include filename="header.htm"
/}
[tagname] => include
[tagfield] =>
[text] =>
[attr] => Array
(
[filename] => header.htm
)
)
[10] => Array
(
[str] => {t:field.title function='Html2Text(@me)' }{/t:field
}
[tagname] => field
[tagfield] => title
[text] =>
[function] => Html2Text(@me)
[attr] => Array
(
)
)
[11] => Array
(
[str] => {t:array name='asdas' }{/t:array
}
[tagname] => array
[tagfield] => asdas
[text] =>
[attr] => Array
(
)
)
[12] => Array
(
[str] => {t:channel typeid='1' row='15'}
[field:id/][field:typename/]
{/t:channel
}
[tagname] => channel
[tagfield] =>
[text] =>
[field:id/][field:typename/]
[attr] => Array
(
[typeid] => 1
[row] => 15
)
)
[13] => Array
(
[str] => {t:channel typeid='1'} [field:id/] [field:typename/]{/t:channel}
[tagname] => channel
[tagfield] =>
[text] => [field:id/] [field:typename/]
[attr] => Array
(
[typeid] => 1
)
)
[14] => Array
(
[str] => {t:channel typeid='1' }[field:id/]
[field:typename/]{/t:channel
}
[tagname] => channel
[tagfield] =>
[text] => [field:id/]
[field:typename/]
[attr] => Array
(
[typeid] => 1
)
)
[15] => Array
(
[str] => {t:channel}[field:typename/]{/t:channel
}
[tagname] => channel
[tagfield] =>
[text] => [field:typename/]
[attr] => Array
(
)
)
[16] => Array
(
[str] => {t:channel typeid='1' row='20' }[field:userid/]
[field:scores/]
{/t:channel
}
[tagname] => channel
[tagfield] =>
[text] => [field:userid/]
[field:scores/]
[attr] => Array
(
[typeid] => 1
[row] => 20
)
)
)
测试代码打包下载
复制代码 代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
{t:arc row='10'}
{t:field.title/}
{t:list row='5'}
{t:field.title/}
{t:list row='5'}
{t:field.title/}
{/t:list}{t:field.title/}
{/t:list}{t:field.title/}
{/t:arc}
{T:channelartlist
row='6'
}
<dl>
<dt>{t:field name='typename'/}{t:field.typename/}</dt>
<dd>
{t:arclist titlelen='42' row='10'}
<ul class='autod'>
<li>[field:title/]</li>
<li>([field:sendtime function="MyDate('m-d',@me)"/])</li>
</ul>
{/t:arclist}
</dl>{/t:channelartlist
}
{t:global.cfg_title
/}{t:var.cfg_title/}{t:global.cfg_webname /}{t:global.cfg_title/}{t:var.cfg_title/}
{t:field.title function="Html2Text(@me)"/}
{t:include
filename="header.htm"/}
{t:include filename="header.htm"
/}
{t:field.title function='Html2Text(@me)' }{/t:field
}
{t:array name='asdas' }{/t:array
}
{t:channel typeid='1' row='15'}
[field:id/][field:typename/]
{/t:channel
}
{t:channel typeid='1'} [field:id/] [field:typename/]{/t:channel}
{t:channel typeid='1' }[field:id/]
[field:typename/]{/t:channel
}sd
{t:channel}[field:typename/]{/t:channel
}
{t:channel typeid='1' row='20' }[field:userid/]
[field:scores/]
{/t:channel
}
</body>
</html>
php代码
复制代码 代码如下:
<?php
$str = file_get_contents("test.htm");
$skstr="{";
$skdstr="t:";
$sdstr="}";
//$reg="/{t:.*?(?:\/).*?}/si";//此无法匹配嵌套,只能一层 si s: 使前面的. 包括换行符 i:不区分大小写
//$reg="/({t:*[^{]*\/}|{t:*[^}]*}([^{]|(?R))*{\/t:.*?})/si";无限嵌套都可截取.
$reg='/('.$skstr.$skdstr.'*[^'.$skstr.']*\/'.$sdstr.'|'.$skstr.$skdstr.'*[^'.$sdstr.']*'.$sdstr.'([^'.$skstr.']|(?R))*'.$skstr.'\/'.$skdstr.'.*?'.$sdstr.')/si';
preg_match_all($reg,$str,$m);
/*echo "<pre>";print_r($m[0]);echo "</pre>";exit();*/
$CTags=array();
$glarr1=array($skstr.$skdstr=>'');//array('{t:'=>'');前缀
$glarr2=array('"'=>'','\''=>'','$'=>'','/'=>'');
/*
{t:array typeid='1'}[field:typename/]{/t:array}
{t:global.title function="html2text(@me)"/}
*/
foreach($m[0] as $k=>$v){
$rarr=array();
$rarr['str']=$v; //原模板字符串
$vs=explode('}',$v); //分割取得第一部分 {t:array typeid='1'
$va=explode(' ',$vs[0]); //分割属性 " {t:array " , " typeid='1' "
$vb=explode('.',$va[0]); //分割标签名和字段名 {t:global.title
$rarr['tagname']=trim(strtr(strtolower($vb[0]),$glarr1));//过滤前缀{t: 取得标签名 array 或 golbal
$rarr['tagfield']=strtr($vb[1],$glarr2); //取得字段名 title
unset($vs[0]);$vsstr=implode('}',$vs); //去掉前缀,返回后半段: [field:typename/]{/t:array}
$rarr['text']=preg_replace("/".$skstr."\/".$skdstr.$rarr['tagname']."(.*?)".$sdstr."/si",'',$vsstr);
/*过滤后缀 {/t:array} 取得中间文本.
可能出现,空格或者换行所以使用正则,也可直接使用strtr 替换 。
{/t:array }
{/t:array
}
strtr(strtolower($vsstr),array($skstr.'/'.$skdstr.$rarr['tagname'].$sdstr=>''));
*/
unset($va[0]);
$attr=array();
foreach($va as $val){//循环记录属性
$val=strtr($val,$glarr2); //typeid='1' 去掉 " ' / , typeid=1
$vc=explode('=',$val);
if(!empty($vc[0])){
$vc[0]=strtolower($vc[0]); //小写属性名
if($vc[0]=="function"){
$rarr['function']=$vc[1]; //返回要执行的 html2text(@me)
}else if($vc[0]=="name"){
$rarr['tagfield']=$vc[1]; //{t:field name='title' /}
}else{
$attr[trim($vc[0])]=$vc[1]; //属性 $attr['typeid']=1;
}
}
}
$rarr['attr']=$attr;
$CTags[$k]=$rarr;
}
echo "<pre>";
print_r($CTags);
echo "</pre>";
?>
输出内容:
复制代码 代码如下:
Array
(
[0] => Array
(
[str] => {t:arc row='10'}
{t:field.title/}
{t:list row='5'}
{t:field.title/}
{t:list row='5'}
{t:field.title/}
{/t:list}{t:field.title/}
{/t:list}{t:field.title/}
{/t:arc}
[tagname] => arc
[tagfield] =>
[text] =>
{t:field.title/}
{t:list row='5'}
{t:field.title/}
{t:list row='5'}
{t:field.title/}
{/t:list}{t:field.title/}
{/t:list}{t:field.title/}
[attr] => Array
(
[row] => 10
)
)
[1] => Array
(
[str] => {T:channelartlist
row='6'
}
{t:field name='typename'/}{t:field.typename/}
{t:arclist titlelen='42' row='10'}
[field:title/]
([field:sendtime function="MyDate('m-d',@me)"/])
{/t:arclist}
{/t:channelartlist
}
[tagname] => channelartlist
[tagfield] =>
[text] =>
{t:field name='typename'/}{t:field.typename/}
{t:arclist titlelen='42' row='10'}
[field:title/]
([field:sendtime function="MyDate('m-d',@me)"/])
{/t:arclist}
[attr] => Array
(
[row] => 6
)
)
[2] => Array
(
[str] => {t:global.cfg_title
/}
[tagname] => global
[tagfield] => cfg_title
[text] =>
[attr] => Array
(
)
)
[3] => Array
(
[str] => {t:var.cfg_title/}
[tagname] => var
[tagfield] => cfg_title
[text] =>
[attr] => Array
(
)
)
[4] => Array
(
[str] => {t:global.cfg_webname /}
[tagname] => global
[tagfield] => cfg_webname
[text] =>
[attr] => Array
(
)
)
[5] => Array
(
[str] => {t:global.cfg_title/}
[tagname] => global
[tagfield] => cfg_title
[text] =>
[attr] => Array
(
)
)
[6] => Array
(
[str] => {t:var.cfg_title/}
[tagname] => var
[tagfield] => cfg_title
[text] =>
[attr] => Array
(
)
)
[7] => Array
(
[str] => {t:field.title function="Html2Text(@me)"/}
[tagname] => field
[tagfield] => title
[text] =>
[function] => Html2Text(@me)
[attr] => Array
(
)
)
[8] => Array
(
[str] => {t:include
filename="header.htm"/}
[tagname] => include
[tagfield] =>
[text] =>
[attr] => Array
(
[filename] => header.htm
)
)
[9] => Array
(
[str] => {t:include filename="header.htm"
/}
[tagname] => include
[tagfield] =>
[text] =>
[attr] => Array
(
[filename] => header.htm
)
)
[10] => Array
(
[str] => {t:field.title function='Html2Text(@me)' }{/t:field
}
[tagname] => field
[tagfield] => title
[text] =>
[function] => Html2Text(@me)
[attr] => Array
(
)
)
[11] => Array
(
[str] => {t:array name='asdas' }{/t:array
}
[tagname] => array
[tagfield] => asdas
[text] =>
[attr] => Array
(
)
)
[12] => Array
(
[str] => {t:channel typeid='1' row='15'}
[field:id/][field:typename/]
{/t:channel
}
[tagname] => channel
[tagfield] =>
[text] =>
[field:id/][field:typename/]
[attr] => Array
(
[typeid] => 1
[row] => 15
)
)
[13] => Array
(
[str] => {t:channel typeid='1'} [field:id/] [field:typename/]{/t:channel}
[tagname] => channel
[tagfield] =>
[text] => [field:id/] [field:typename/]
[attr] => Array
(
[typeid] => 1
)
)
[14] => Array
(
[str] => {t:channel typeid='1' }[field:id/]
[field:typename/]{/t:channel
}
[tagname] => channel
[tagfield] =>
[text] => [field:id/]
[field:typename/]
[attr] => Array
(
[typeid] => 1
)
)
[15] => Array
(
[str] => {t:channel}[field:typename/]{/t:channel
}
[tagname] => channel
[tagfield] =>
[text] => [field:typename/]
[attr] => Array
(
)
)
[16] => Array
(
[str] => {t:channel typeid='1' row='20' }[field:userid/]
[field:scores/]
{/t:channel
}
[tagname] => channel
[tagfield] =>
[text] => [field:userid/]
[field:scores/]
[attr] => Array
(
[typeid] => 1
[row] => 20
)
)
)
测试代码打包下载
DDR爱好者之家 Design By 杰米
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
DDR爱好者之家 Design By 杰米
暂无评论...
稳了!魔兽国服回归的3条重磅消息!官宣时间再确认!
昨天有一位朋友在大神群里分享,自己亚服账号被封号之后居然弹出了国服的封号信息对话框。
这里面让他访问的是一个国服的战网网址,com.cn和后面的zh都非常明白地表明这就是国服战网。
而他在复制这个网址并且进行登录之后,确实是网易的网址,也就是我们熟悉的停服之后国服发布的暴雪游戏产品运营到期开放退款的说明。这是一件比较奇怪的事情,因为以前都没有出现这样的情况,现在突然提示跳转到国服战网的网址,是不是说明了简体中文客户端已经开始进行更新了呢?
更新日志
2024年11月26日
2024年11月26日
- 凤飞飞《我们的主题曲》飞跃制作[正版原抓WAV+CUE]
- 刘嘉亮《亮情歌2》[WAV+CUE][1G]
- 红馆40·谭咏麟《歌者恋歌浓情30年演唱会》3CD[低速原抓WAV+CUE][1.8G]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[320K/MP3][193.25MB]
- 【轻音乐】曼托凡尼乐团《精选辑》2CD.1998[FLAC+CUE整轨]
- 邝美云《心中有爱》1989年香港DMIJP版1MTO东芝首版[WAV+CUE]
- 群星《情叹-发烧女声DSD》天籁女声发烧碟[WAV+CUE]
- 刘纬武《睡眠宝宝竖琴童谣 吉卜力工作室 白噪音安抚》[FLAC/分轨][748.03MB]
- 理想混蛋《Origin Sessions》[320K/MP3][37.47MB]
- 公馆青少年《我其实一点都不酷》[320K/MP3][78.78MB]
- 群星《情叹-发烧男声DSD》最值得珍藏的完美男声[WAV+CUE]
- 群星《国韵飘香·贵妃醉酒HQCD黑胶王》2CD[WAV]
- 卫兰《DAUGHTER》【低速原抓WAV+CUE】
- 公馆青少年《我其实一点都不酷》[FLAC/分轨][398.22MB]
- ZWEI《迟暮的花 (Explicit)》[320K/MP3][57.16MB]