Getting only numbers instead of values when using regular expression groups in Visual Basic 2008 express

Hi all,

I have a regular expression in visual basic .net 2008. I am using it
to validate the file names of reports I recieve. I want to use groups
in regular expressions to extract information from the file name.
Whenever I access any item of the groups collection though I can only
see a number. I see no names.

My regular expression is as follows.
(?<fName>\w)+_(?<lName>\w)+\-(\w|\D)+to(\w|\d)+_(?<projectName>\w)+\.xls$

my test string looks like
Pranav_Lal-25To30May2008_vita.xls

Any one any ideas? I am posting the full source of the test program below.

Pranav
Imports System.Text.RegularExpressions

Module Module1

    Sub Main()
        Dim rString As String =
"(?<fName>\w)+_(?<lName>\w)+\-(\w|\D)+to(\w|\d)+_(?<projectName>\w)+\.xls$"

        Try
            Dim TestRegex As Regex = New Regex(rString, RegexOptions.IgnoreCase)

            Dim S As String = "pranav_lal-12To23April2008_veta.xls"

            Dim M As Match = TestRegex.Match(S)
            If M.Success Then
                Console.WriteLine("ok")
            Else
                Console.WriteLine("error")

            End If
            Dim groups As GroupCollection = M.Groups
            Console.WriteLine(groups.Item(1).Value)

        Catch x As ArgumentException
            Console.WriteLine(x.ToString)
        End Try
        Console.WriteLine("Hit <enter> to exit...")

        Console.ReadLine()


    End Sub
End Module
__________
View the list's information and change your settings at 
http://www.freelists.org/list/programmingblind

Other related posts: