使用 TypeProviders
使用 TypeProviders
#r @"D:\工具\TypeProviders\packages\FSharpx.TypeProviders.Regex.1.7.4\lib\40\FSharpx.TypeProviders.Regex.dll";;
type T = FSharpx.Regex< @"(?<AreaCode>^\d{3})-(?<PhoneNumber>\d{3}-\d{4}$)">let reg = T() let result = T.IsMatch("425-123-2345")let r1 = reg.Match("425-123-2345").AreaCode.Value let r2 = reg.Match("425-123-2345").PhoneNumber.Valuereg.Match("425-123-2345").Groups.Countreg.Match("425-123-2345").Groups.[0].Valuereg.Match("425-123-2345").Groups.[1].Valuereg.Match("425-123-2345").Groups.[2].Valuereg.Match("425-123-2345").Groups.[4].Valuereg.GetGroupNumbers().Lengthreg.GetGroupNames()