preg 替换以删除 bbcode 引用

发布于 2024-09-09 04:56:20 字数 187 浏览 3 评论 0原文

有人可以给我一个例子,说明如何删除

[QUOTE=author;3095231]

作者(作者姓名)和 3095231(帖子)。

我想使用 preg 替换,或任何类似的东西,但不确定如何使用,并且想知道一个例子,我相信它会类似于 [QUOTE=(.+?)] 其余的我就不知道了。

Could someone give me an example of how to I can remove

[QUOTE=author;3095231]

Author being the authors name, and 3095231 being the post.

I want to use preg replace, or anything similar but not sure how and was wondering for an example, I believe it would be something like [QUOTE=(.+?)]
and i don't know the rest.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

撩人痒 2024-09-16 04:56:20

你的正则表达式对我来说看起来几乎正确,但你必须转义括号。

假设它是用 PHP 编写的,相应的代码如下所示

$text = preg_replace('/\[QUOTE=(.+?)\]/', '', $text);

Your regex looks almost right to me, you must escape the brackets though.

Assuming it's in PHP, the corresponding code would look like

$text = preg_replace('/\[QUOTE=(.+?)\]/', '', $text);
萌逼全场 2024-09-16 04:56:20

您正在寻找的正则表达式是

s/\[QUOTE=[^\]]+\]//

The regular expression you're looking for is

s/\[QUOTE=[^\]]+\]//
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文