fork download
  1. Imports System
  2. Imports System.Text.RegularExpressions
  3.  
  4. Public Class Test
  5. Public Shared Sub Main()
  6. Dim FileLines() As String = New String() {"test", "I am a line", "cool:", "username: Hello123", "Username: John", "Hello there", "USERnaMe: J.Johnsson", "test again"}
  7.  
  8. Console.WriteLine("--- Input lines ---")
  9.  
  10. For Each InputLine As String In FileLines
  11. Console.WriteLine(InputLine)
  12. Next
  13.  
  14. Console.WriteLine(Environment.NewLine & "--- Found usernames ---")
  15.  
  16. Dim RgEx As New Regex("(?<=username:\s).+", RegexOptions.IgnoreCase) 'Declare a new, case-insensitive Regex.
  17. For Each Line As String In FileLines
  18. Dim m As Match = RgEx.Match(Line)
  19. If m IsNot Nothing AndAlso m.Success = True Then
  20. Console.WriteLine(m.Value)
  21. End If
  22. Next
  23. End Sub
  24. End Class
Success #stdin #stdout 0.08s 24504KB
stdin
Standard input is empty
stdout
--- Input lines ---
test
I am a line
cool:
username: Hello123
Username: John
Hello there
USERnaMe: J.Johnsson
test again

--- Found usernames ---
Hello123
John
J.Johnsson