Android Question Extract Number from alphanumeric string

Discussion in 'Android Questions' started by Kiran Raotole, Jun 5, 2019.

  1. Kiran Raotole

    Kiran Raotole Active Member Licensed User

    My string = "AND051"

    How extract number from this string?

    like new variable = 051 / 51
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Code:
    Dim s As String = "AND051"
    Dim m As Matcher = Regex.Matcher("\d+", s)
    If m.Find Then
       
    Dim number As Int = m.Match
       
    Log(number)
    End If
     
    AnandGupta, MarkusR and MarcoRome like this.
  3. emexes

    emexes Well-Known Member Licensed User

  4. Erel

    Erel Administrator Staff Member Licensed User

    emexes likes this.
  5. emexes

    emexes Well-Known Member Licensed User

    I like that it provides the code.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice