カタカナはそのままで、数字、アルファベット、一部記号を半角変換。

Public Function abc123ToHankaku(ByVal s As String) As String

Dim re As Regex = New Regex("[0-9A-Za-z():,- ]+")
Dim output As String = re.Replace(s, AddressOf myReplacer)

Return output
End Function

Private Function myReplacer(ByVal m As Match) As String
Return Strings.StrConv(m.Value, VbStrConv.Narrow, 0)
End Function





関連 2012-01-19 22:21:19