我正在使用Like
运算符进行模式搜索。到目前为止,这是我想出的:
if MyString Like "*sometext?" + "_*" then
debug.print "Match found!"
else
debug.print "Not a match"
只有在sometext
和之间的字符_
是一个数字(只有一个数字,没有字母数字)时,我才需要匹配它。例如:
MyString='testingsometext3_whatever'
应该是一个比赛,
MyString='testingsometext321_whatever'
不应该是一个匹配项(有3个数字,而不仅仅是一个数字)
MyString='testingsometext_whatever'
不应为匹配项,因为text
和之间没有字符_
MyString='testingsometexts_whatever'
不应该是一个匹配项(text
和之间至少有一个字母数字_
)-这是目前不适合我的内容,我需要帮助
由于OP似乎认为这是最直接的答案:
if MyString Like "*sometext#_*" then
debug.print "Match found!"
else
debug.print "Not a match"
end if
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句