EXCEL自身的函數沒有能實現這樣功能的,只有用VBA編程定義壹個函數來實現,效果如下圖:
上面的公式為:
=RegReplace(A1,"<\{.*?\}>[\s\n\r]*","")
其中的RegReplace是自定義函數,需要按ALT+F11添加模塊實現,代碼是這個樣子:
代碼的文本為:
Option Explicit
Function RegReplace(ByVal str1$, ByVal find$, ByVal rep$) As String
Dim re
Set re = CreateObject("VBScript.RegExp")
re.Pattern = find
re.Global = True
re.IgnoreCase = True
re.MultiLine = True
RegReplace = re.Replace(str1, rep)
End Function