RegEx - 如何摆脱这两个括号之间的所有内容,包括括号?

发布于 2024-12-05 02:55:01 字数 380 浏览 0 评论 0原文

我在编写正则表达式方面没有取得任何进展,需要一些帮助。

我需要去掉两个括号之间的所有内容,包括两个括号。

我已经尝试了我能想到的一切,但没有运气。

<cfscript>
MyString = "Eat some [pizza] with beer.";
MyString = reReplaceNoCase(MyString, "", "", "all");
writeOutput(MyString);
</cfscript>

在文本编辑器中,我使用了以下字符串,它运行得很好,但我无法让它在 ColdFusion 中运行。

^[*^]

你能帮助我吗?

I am making NO headway in writing a regular expression and need some help.

I need to get rid of everything between two brackets including the two brackets.

I have tried everything I could think of with no luck.

<cfscript>
MyString = "Eat some [pizza] with beer.";
MyString = reReplaceNoCase(MyString, "", "", "all");
writeOutput(MyString);
</cfscript>

In a text editor, I was using the following string and it worked perfectly well, but I can't get it working in ColdFusion.

^[*^]

Can you help me?

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

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

发布评论

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

评论(1

紫竹語嫣☆ 2024-12-12 02:55:01
\[[^\]]*]

您必须转义括号,否则它们将被解释为“这些括号内的任何字符”

\[[^\]]*]

You have to escape the brackets or they will be interpreted as "any character inside these brackets"

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