VB.Net Tutorial/Regular Expressions/MatchCollection

Материал из VB Эксперт
Перейти к: навигация, поиск

Use MatchCollection

Imports System.Text.RegularExpressions
Public Class Tester
    Public Shared Sub Main
        Dim source As String = "This 7. several 0.9 numbers"
        Dim parser As New Regex( _
           "[-+]?([0-9]*\.)?[0-9]+([eE][-+]?[0-9]+)?")
        Dim sourceMatches As MatchCollection = _
           parser.Matches(source)
        Dim result As Double = CDbl(sourceMatches(1).Value)
        Console.WriteLine(result.ToString())
    End Sub

End Class
0.9