How can i Remove line number at the beginning ?

sandrine10

Power Member
Joined
Apr 14, 2010
Messages
779
Reaction score
88
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 ?
 
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
 
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:
Back
Top