在Excel中删除字符串中的特定字符串

在Excel中删除字符串中的特定字符串,excel,excel-formula,Excel,Excel Formula,在Excel中,我有以下字符串: U########## B########## ############ (Last two digits are term indicator) ############ (Last two digits are term indicator) OLF####### or OLTD####### or OLF######### (Last two digits are the term indicator) or OLTD######### (Las

在Excel中,我有以下字符串:

U########## 

B##########

############ (Last two digits are term indicator)

############ (Last two digits are term indicator)

OLF####### or OLTD####### or OLF######### (Last two digits are the term indicator) or OLTD######### (Last two digits are term indicator) or 

OICF######### (Last two digits are term indicator) 09-##########-## (Last two digits are the term indicator)

OL######## or OLT####### or OL######### (Last two digits are the term indicator) or OLT######### (Last two digits are the term indicator) or OIC########## (Last two digits are the term indicator)

UDC_#######_##_01 or  UDV_#######_##_01 or UWD_#######_##_01 (11th & 12th digits are the term indicator)
我的目标是删除括号中的中间字符串或结束字符串。最后两位数字是术语指示器


我正在寻找一个公式或vb代码,这将帮助我删除这些字符串中包含的论文。提前感谢。

需要TEXTJOIN和FILTERXML,两者都是较新的公式,可能无法在所有版本中提供:

=TRIM(SUBSTITUTE(TEXTJOIN(" ",,FILTERXML("<a><b>"&SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"&","|"),"(","</b>"),")","<b>")&"</b></a>","//b[string-length(.)>0]")),"|","&"))

我试过这个,效果很好。我在第一个单元格B2上输入了公式并输入了它。然后,当我双击右下角复制公式时,相同的字符串,即,如果第一个单元格A2包含&,则在其他单元格B2:B250上复制公式的值相同,并在其他单元格上重复。当我转到下一个单元格(即B3)并检查公式并按enter键时,我得到的是正确的字符串,即如果A3包含&┱,那么B3也包含&┱…在此之前B3是&&您的计算可能未设置为自动。试着打F9。好棒的斯科特!+=@JvdV花了我整整20分钟才发现FILTERXML不喜欢&。是的,如果您需要在字符串检查中以某种方式使用它,请使用&。顺便说一句,使用//b[node]可以得到相同的结果。times FILTERXML非常有用=
=TRIM(TEXTJOIN(" ",,FILTERXML("<a><b>"&SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(A1,"&","&amp;"),"(","</b>"),")","<b>")&"</b></a>","//b[string-length(.)>0]")))