如何让我的程序检查字符串是否以VB.NET中的某些内容开头?在vb.net中使用类似www。*或东西的表达式
例如:
dim examplestr as string
examplestr = textbox1.text
if examplestr = ("www." + %something%) then
examplestr = ("http://" + examplestr)
elseif examplestr = ("http://" + %something%) then
else
if examplestr = (%something%) then
examplestr = ("http://www." + examplestr
end if
不起作用。匹配'“wwwgooglecom”'和'“awww”'。你的代码基本上是's.Contains(“www”)'不'sStartsWith(“www。”)'。 '.'不是文字,它是通配符,你忘了匹配字符串start + end。 – CodesInChaos
@CodesInChaos你是对的,我修改了我的答案。 – JMK