1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How can i Remove line number at the beginning ?

Discussion in 'Visual Basic .NET' started by sandrine10, Jan 12, 2014.

  1. sandrine10

    sandrine10 Power Member

    Joined:
    Apr 14, 2010
    Messages:
    621
    Likes Received:
    63
    Location:
    CyberLand
    How to delete line number at the beginning ,ie:
    1email:string:string
    2email:string:string
    3email:string:string
    4email:string:string
    .
    .
    .
    .etc
    how to remove numbers 1,2,3,..etc ?
     
  2. mypmmail

    mypmmail Junior Member

    Joined:
    Jan 31, 2008
    Messages:
    111
    Likes Received:
    27
    I assume that your starting is always a number.

    Thus, what you can do is to use regular expression to match the first number and then extract the rest of the data except the numbers

    Code:
        Sub Main()
    	' The input string.
    	Dim value As String = "1email:string:string"
    
    	Dim m As Match = Regex.Match(value,  "\d+(.*)",  RegexOptions.IgnoreCase)
    
    	If (m.Success) Then
    	    Dim lineWithoutNumber As String = m.Groups(1).Value
    	    Console.WriteLine(lineWithoutNumber )
    	End If
        End Sub
    
     
  3. normanbates1

    normanbates1 Registered Member

    Joined:
    Jul 24, 2012
    Messages:
    76
    Likes Received:
    21
    I use 'ultraedit' which does that no problem.
     
  4. tahworld

    tahworld Regular Member

    Joined:
    Aug 16, 2013
    Messages:
    457
    Likes Received:
    393
    Location:
    ✔✔✔✔✔✔✔
  5. mandingo

    mandingo Newbie

    Joined:
    Jan 29, 2014
    Messages:
    10
    Likes Received:
    2
    A bit easier this way...

    Code:
    Sub Main()
          
         'Input string
         Dim strString as String = "1email:string:string"
         
         'Get the position of "email" and add 1 since Mid needs to start with 1 
         'Cut out the part of the string we want via Mid since we now know the correct position to trim from
         strString = Mid(strString, strString.IndexOf("email") + 1) 
         
         'Show the output   
         Console.WriteLine(strString)
            
    End Sub
    
     
    Last edited: Feb 2, 2014
  6. r000k

    r000k Registered Member

    Joined:
    Jan 10, 2013
    Messages:
    66
    Likes Received:
    30
    just strip numbers with regex