如何在visual basic中找到Textbox中的多个数字

时间:2014-06-22 06:31:29

标签: vb.net parsing

我的文本文本框是"ab1234de524sfe6985dsef456",我希望将此中的所有数字都带到数组中 喜欢

arr(0)=1234,
arr(1)=524,
arr(2)=6985,
arr(3)=456

帮助我,谢谢

2 个答案:

答案 0 :(得分:0)

您可以使用Regex.Check下面用c#

编写的代码段
string strRegex = @"\d+";
Regex myRegex = new Regex(strRegex, RegexOptions.Singleline);
string strTargetString = @"ab1234de524sfe6985dsef456";
ArrayList list=new ArrayList();
foreach (Match myMatch in myRegex.Matches(strTargetString))
{
  if (myMatch.Success)
  {
    list.Add(myMatch.Value);
  }
}

list.Dump();

答案 1 :(得分:0)

转换为Visual Basic:

Dim strRegex As String = "\d+"
Dim myRegex As New Regex(strRegex, RegexOptions.Singleline)
Dim strTargetString As String = "ab1234de524sfe6985dsef456"
Dim list As New ArrayList()
For Each myMatch As Match In myRegex.Matches(strTargetString)
    If myMatch.Success Then
        list.Add(myMatch.Value)
    End If
Next