Android Question Regex split

Discussion in 'Android Questions' started by PassionDEV, Jul 7, 2019.

  1. PassionDEV

    PassionDEV Active Member Licensed User

    i have this following text

    Code:
    dim data as string = "Marten~Samuel~~~Martha~"
    dim parser() As String

    parser = 
    Regex.Split("\~", data)

    i expect to get Length of 5 , but i got Length of 3

    why the empty ~ doesn't count in the parser ?
     
  2. DonManfred

    DonManfred Expert Licensed User

    Code:
    Dim data As String = "Marten~Samuel~~~Martha~"
        
    Dim parser() As String

        parser = 
    Regex.Split("~", data)
        
    Log($"Splitted Size: ${parser.Length} "$)
        
    For i= 0 To parser.Length-1
           
    Log($"Val #${i}=${parser(i)}"$)
       
    Next
    Logs a size of 5 like i was expecting where #2 and #3 are empty.

     
    Erel likes this.
  3. PassionDEV

    PassionDEV Active Member Licensed User

    weird i think something wrong with my text formatting i was shocked
     
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