问题
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