Home > Backend Development > PHP Tutorial > 求个正则 高难度的

求个正则 高难度的

WBOY
Release: 2016-06-23 13:29:02
Original
1112 people have browsed it


[m:cname]
 

变成 (关键在 如果 上方
[list:cname]
 

变成 



[list:cname]



===============================

如果多层,这个很有挑战性 ,不知道正则行不行 如果行 给多加分



[channel:cname]


[artlist:title]

 


转为


[channel:cname]

   
       [artlist:title]
   

 


 


回复讨论(解决方案)

$s =<<< 'TXT'<!--m:{ $Row=10 $table=Channel $Where=[FatherID]=0 }--><a href="[m:curl]">[m:cname]</a><!--m--> <!--list:{ $Row=10 $table=Channel $Where=[FatherID]=0 }--><a href="[list:curl]">[list:cname]</a><!--list--> <!--channel:{ $row=10 $table=channel  }--><a href="[channel:curl]">[channel:cname]</a><!--artlist:{ $row=6 $cid=[channel:childids] $order=[order] desc,[id] desc }--><a href="[artlist:aurl]">[artlist:title]</a><!--artlist--> <!--channel-->TXT;$p = array(  '/<!--(\w+):{ \$Row=(\d+)(.+)}-->/i',  '/<!--\w+-->/',);$r = array(  '<qlist listname="$1"  row="$2"$3>',  '</qlist>',);echo preg_replace($p, $r, $s);
Copy after login
<qlist listname="m"  row="10" $table=Channel $Where=[FatherID]=0 ><a href="[m:curl]">[m:cname]</a></qlist> <qlist listname="list"  row="10" $table=Channel $Where=[FatherID]=0 ><a href="[list:curl]">[list:cname]</a></qlist> <qlist listname="channel"  row="10" $table=channel  ><a href="[channel:curl]">[channel:cname]</a><qlist listname="artlist"  row="6" $cid=[channel:childids] $order=[order] desc,[id] desc ><a href="[artlist:aurl]">[artlist:title]</a></qlist> </qlist>
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template