visual basic 2010如何在字符串中找到“=”

时间:2012-05-01 20:06:20

标签: vb.net visual-studio-2010

string = "I was born in = 1994"

如何在var?

中存储“=”之后的所有值

3 个答案:

答案 0 :(得分:3)

这是最简单的方法:

Dim var = s.Substring(s.IndexOf("="c) + 1)

答案 1 :(得分:1)

您可以使用split功能:

  Dim [string] = "I was born in = 1994"
  Dim temp() As String = Split([string], " = ", -1, CompareMethod.Binary)
  'now value is in temp(1)
  MessageBox.Show(temp(1))

答案 2 :(得分:0)

有许多方法,我会在字符串中使用。

mystring as new string
mystring  = "I was born in =1994"
DataAfterEquals as string = mid(mystring,instr(mystring,"=")+1,mystring.length-instr(mystring,"=")+1)

你当然可以使用正则表达式,使用拆分,然后当然你可以去旧时尚并迭代查找等号的字符串。

上面的代码会找到第一个等号,然后从字符串中的那个点向外解析,所以我添加+1来跳过等号。这个伪代码。