正規表現転換機

 

 

  '詳細情報
            Dim information As String = myDB.GetDataStrType(m_dr, "information")
            information = myFunc.GetUrlSQL(information)

            '電話番号を自動リングにする。
            Dim myRegex As System.Text.RegularExpressions.Regex = New System.Text.RegularExpressions.Regex("0[0-9]{1,3}-[0-9]{2,4}-[0-9]{4}")
            information = myRegex.Replace(information, New MatchEvaluator(AddressOf RepTel))

            'メールアドレスを自動リングにする。
            myRegex = New System.Text.RegularExpressions.Regex("[A-Za-z0-9_/-][A-Za-z0-9_/./-]*@([A-Za-z0-9_/-]+/.)+(com|jp)")
            information = myRegex.Replace(information, New MatchEvaluator(AddressOf RepMailAddr))

            'HTTPを自動リングにする。
            'myRegex = New System.Text.RegularExpressions.Regex("http(s)?://([/w-]+/.)+[/w-]+(/[/w- ./?%&=]*)?")
            myRegex = New System.Text.RegularExpressions.Regex("http(s)?://([/w-]+/.)+[/w-]+(/[/w-./?%&=]*)?")
            information = myRegex.Replace(information, New MatchEvaluator(AddressOf RepUrl))

 

 

 

 ''' <summary>
    ''' 電話番後変換
    ''' </summary>
    ''' <param name="mt"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Private Function RepTel(ByVal mt As Match) As String
        Return String.Format("<a href= ""tel:{0}"">{0}</a>", mt.Value)
    End Function

    ''' <summary>
    ''' メールアドレス変換
    ''' </summary>
    ''' <param name="mt"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Private Function RepMailAddr(ByVal mt As Match) As String
        Return String.Format("<a href= ""mailto:{0}"">{0}</a>", mt.Value)
    End Function

    ''' <summary>
    ''' URLを変換
    ''' </summary>
    ''' <param name="mt"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Private Function RepUrl(ByVal mt As Match) As String
        Return String.Format("<a href= ""{0}"">{0}</a>", mt.Value)
    End Function

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值