使用 TypeProviders

来源:互联网 发布:外国人看李小龙知乎 编辑:程序博客网 时间:2024/06/16 16:30
使用 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.Value
reg.Match("425-123-2345").Groups.Count
reg.Match("425-123-2345").Groups.[0].Value
reg.Match("425-123-2345").Groups.[1].Value
reg.Match("425-123-2345").Groups.[2].Value
reg.Match("425-123-2345").Groups.[4].Value
reg.GetGroupNumbers().Length
reg.GetGroupNames()

原创粉丝点击