On Apr 18, 5:06*pm, Jeannot <jean...@hawk.igs.netwrote:
Dim re As New Regex("\s([0-9]+)\s")
Dim mc As Match = re.Match("Puppy measures * * * *13 * * *inches ")
Dim s As String = mc.Groups.Item(0).ToString()
s is " 13 " with a leading and a trailing space, and driving me nuts.
My set of parenthesis clearly specify only digits, where do the spaces
come from???.
What am I doing wrong????
well... the primary match is " 13 " because of the \s so, if you look
at group item 1, it will be 13:
mc.Groups.Item(1).Value
In other words, the expression matches the entire expression, the
parens are a sub match. You could just write it like this:
"\d+"
Dim s As String = "Puppy measures 13 12 inches "
Dim matches As MatchCollection = Regex.Matches(s, "\d+")
For Each m As Match In matches
Console.WriteLine(m.Value)
Next
HTH
--
Tom Shelton