通过排除空格和特殊字符来匹配单词

时间:2015-02-26 06:35:02

标签: excel

我正在尝试匹配不同单元格中的以下单词。

shirtsize   shirt size 42

shirt Size  shirt size

shirt-size  shirt size 42

shirt - Size    shirt,size

以下是我正在使用的功能,但它没有给出预期的结果。

Function ExactWordInString(Text As String, Word As String) As Boolean
     ExactWordInString = " " & UCase(Text) & " " Like "*[!A-Z]" & UCase(Word) & "[!A-Z]*"
End Function

1 个答案:

答案 0 :(得分:0)



Function ExactWordInString(Text As String, Word As String) As Boolean
     ExactWordInString = " " & UCase(Text) & " " Like "*[!A-Z]" & UCase(Word) & "[!A-Z]*"
End Function






Function ExactWordInString(Text As String, Word As String) As Boolean
     ExactWordInString = " " & UCase(Text) & " " Like "*[!A-Z]" & UCase(Word) & "[!A-Z]*"
End Function




大家好,请找下面的例子。



Column1	                Column2	        Result	Expected Result
Air Force One	        Force	        TRUE	TRUE
Air Force-One	        Force	        FALSE	TRUE
Air "Force" One	        Force	        FALSE	TRUE
United States Brands	United States	FALSE	TRUE
UnitedStates Brands	    United States	FALSE	TRUE
United-States Brands	United States	FALSE	TRUE