Search code examples
vb.netsplitsplit-function

How Do I get this Split Function to Work? (VB.NET)


So, I made a program that for the most part, converts numbers to letters. My problem before was it was converting each individual digit instead of each number e.g. (1-0-1 instead of 101). Someone suggested that I use the Split function:

    Dim numbers As String() = DTB.Split(" ")

So now it's reading the number all the way through being that it will only the split if there's a space in between. My problem now is that it's translating for example: "[102, 103, 104]" as "[102", "103" and "104]" because it will only split if there's a space between. Obviously, you can't convert "[102" or "104]" because they aren't actual numbers.

Does anyone have a solution on what I should do to get this to convert no matter the spacing? Would Regex be the way to go?


Solution

  • use a regular expression with \d+ it will match numbers

    so

    12234abcsdf23434
    

    will return two matches

    12234
    23434