通过RegEx剥离BBCode [英] Strip BBCode via RegEx

查看:65
本文介绍了通过RegEx剥离BBCode的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置一个可检测到[quote] ??? [/quote]并将其删除的正则表达式.

I am trying to setup a regex that will detect [quote]???[/quote] and will remove it.

这是我所拥有的,但不起作用:

This is what I have but it is not working:

$post['body'] = preg_replace("/\[quote\](.+?)\[\/quote\]/is", '', $post['body']);

有人能指出我正确的方向吗?

Can anyone point me in the right direction?

我还想删除[quote] ??? [/quote]之前或之后的所有线路制动器.

I also want to remove any line brakes before or after the [quote]???[/quote].

推荐答案

只是想出了我自己的问题.

Just figured out my own issue.

$post['body'] = preg_replace("/\[quote\](.+?)\[\/quote\]/is", '', $post['body']); $body = trim(rtrim($post[0]['body']));

这篇关于通过RegEx剥离BBCode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆