博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
字符串分割 php标签,php – Puzzle:正确分割HTML字符串
阅读量:4363 次
发布时间:2019-06-07

本文共 554 字,大约阅读时间需要 1 分钟。

function stripmore($in)

{

list($p1,$p2) = explode("read_more()",$in,2);

$pass1 = preg_replace("~>[^<>]+

$pass2 = preg_replace("~^[^<>]+~","",$pass1);

$pass3 = null;

while ( $pass3 != $pass2 )

{

if ( $pass3 !== null ) $pass2 = $pass3;

$pass3 = preg_replace("~]+)>\\1>~","",$pass2);

}

return $p1."read_more()".$pass3;

}

这会删除read_more()标记之后的任何非html,并通过剥离相应的标记将其减少到最小值,同时保持任何标记在标记之前和结束之后开始:

Some text here. read_more()

==>

Some text here. read_more()

Some text read_more() here.

==>

Some text read_more()

Some text read_more() here.

==>

Some text read_more()

转载地址:http://jqkfs.baihongyu.com/

你可能感兴趣的文章
JS-- 小细节--你悟到了什么?
查看>>
收款 借贷
查看>>
Gson关于抽象类的序列化与反序列化
查看>>
Java面向对象之类和对象
查看>>
Oracle数据库提权(dba权限执行系统命令)
查看>>
Hydra爆破神器使用
查看>>
java.util.zip.ZipException: duplicate entry(重复依赖多版本的类库)
查看>>
Run MVC in older version of IIS
查看>>
Ajax 监听
查看>>
隐藏"站长统计"图标
查看>>
Oracle select 中case 的使用以及使用decode替换case
查看>>
创建一个dynamics 365 CRM online plugin (十二) - Asynchronous Plugins
查看>>
Eclipse 常用快捷键 (动画讲解)
查看>>
233 Matrix(矩阵快速幂+思维)
查看>>
Leetcode-Unique Binary Search Trees II
查看>>
Centos7系统下安装Docker
查看>>
PostgreSQL 序列(SEQUENCE)
查看>>
Missing Number
查看>>
Ionic3 demo TallyBook 实例3
查看>>
laravel服务容器
查看>>