删除 Coldfusion 中括号之间的数据

Remove data between brackets in Coldfusion

我正在尝试使用 Coldfusion 删除括号之间的所有数据并添加冒号以标识数据中断。以下是字符串

的示例

[FIRE] A16 - 检查其中一辆车中的未成年少年 [05/01/21 19:07:31 LENDOWS] 拒绝来电者的 COVID 问题 [05/01/21 18:57:21 JJONES] 一辆车不能开,另一方说他们没有保险信息 [05/01/21 18:55:55 JJONES] [FIRE] 获得拒绝

最后看起来像:

A16 - 检查其中一辆车中的未成年少年:拒绝来电者的 COVID 问题:一辆汽车无法驾驶,另一方说他们没有保险信息:获得拒绝:

您想要的正则表达式是\[.*?\]

<cfset str = "[FIRE] A16 - check up to underage juvn in one of the cars 
[05/01/21 19:07:31 LENDOWS] NO TO COVID QUESTIONS FOR CALLER [05/01/21 
18:57:21 JJONES] one car not driveable, other party says they don`t have 
insurance info [05/01/21 18:55:55 JJONES] [FIRE] refusal obtained">

<cfset newStr = reReplace(str, "\[.*?\]", ":", "ALL")>

<cfoutput>#newStr#</cfoutput>

这将准确输出您要求的内容,将 [*] 替换为 :

: A16 - check up to underage juvn in one of the cars : NO TO COVID QUESTIONS
 FOR CALLER : one car not driveable, other party says they don`t have 
insurance info : : refusal obtained

请注意,您有一个前导 : 和几个双打,其中有两组括号内的文本相互跟随。您可以从这里清理文本。