Imports System
Imports System.Text.RegularExpressions
Public Class Test
Public Shared Sub Main()
Dim TestString As String = "[10:56:49] [Client thread/ERROR]: Item entity 26367127 has no item?!" & Environment.NewLine & _
"[10:57:25] [Dbutant] misterflo13 : ils coute chere les enchent aura de feu et T2 du spawn??*" & Environment.NewLine & _
"[10:57:35] [Amateur] firebow ?.SkyLegend.? : ouai 0" & Environment.NewLine & _
"[10:57:38] [Novice] iPasteque : ils sont gratuit me" & Environment.NewLine & _
"[10:57:41] [Novice] iPasteque : ils sont gratuit mec *" & Environment.NewLine & _
"[10:57:46] [Dbutant] misterflo13 : on ma dit k'ils etait payent :o" & Environment.NewLine & _
"[10:57:57] [Novice] iPasteque : on t'a mytho alors"
Console.WriteLine(ReplaceTime("[06:34:22] Hello there!"))
Console.WriteLine(ReplaceTime("[22:47] Hi!"))
Console.WriteLine("-------------------------------------")
Console.WriteLine(ReplaceTimeMultiline(TestString))
End Sub
Public Shared Function ReplaceTime(ByVal Input As String) As String
Dim m As Match = Regex.Match(Input, "(\[)(\d{1,2}\:\d{1,2}(\:\d{1,2})?)(\])(.+)")
Return m.Groups(1).Value & m.Groups(4).Value & m.Groups(5).Value
End Function
Public Shared Function ReplaceTimeMultiline(ByVal Input As String) As String
Dim ReturnString As String
Dim Parts() As String = Input.Split(Environment.NewLine)
For x As Integer = 0 To Parts.Length - 1
ReturnString &= ReplaceTime(Parts(x)) & If(x < (Parts.Length - 1), Environment.NewLine, "")
Next
Return ReturnString
End Function
End Class