Need help with Regular Expressions

SaskiasImp

New member
Joined
Aug 22, 2003
Messages
2
Im just learning VB.NET and now Regular Expressions so please keep it simple. Here is a sample of the strings I am working with:
"15-aug-2003 20:03:13 16010630343646 00:05:28
 
Last edited by a moderator:
You can define matches in the regular expression and pull them out using the Matches property. A group has the syntax:
(?<Time> ... )
Where the ... is the regular expression, such as:
(?<Time>(\d{2}:\d{2}:\d{2})


C#:
Regex regex = new Regex("(?<Time>(\d{2}:\d{2}:\d{2})");
Match match = regex.Match("15-aug-2003 20:03:13 16010630343646 00:05:28
 
How would I use that (in VB.NET) to find the second occurance of the time? Sorry I dont really understand how to use groups like that. Here is my current test code that extracts the 2nd "time" but it relies on the "
 
The object and method calls are identical in VB. You can use the Matches property instead of the Match property to get a list of all matches.

C#:
Regex regex = new Regex(@"(?<Time>(\d{2}:\d{2}:\d{2}))");
foreach(Match timeMatch in regex.Matches("15-aug-2003 20:03:13 16010630343646 00:05:28
 
Back
Top