RegEx - How to get rid of everything between these two brackets, including the brackets?

拥有回忆 提交于 2020-01-04 09:19:32

问题


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?


回答1:


\[[^\]]*]

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



来源:https://stackoverflow.com/questions/7462115/regex-how-to-get-rid-of-everything-between-these-two-brackets-including-the-b

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!