Excel编写自定义方法提取汉字
1、打开excel,按住alt+F11打开编写面板
2、插入下列脚本
Function tiqu(str As String, i As Integer) If i = 1 Then a = "[^A-Za-z]" ElseIf i = 2 Then a = "[^0-9]" ElseIf i = 3 Then a = "[^\u4e00-\u9fa5]" End If Set regEx = CreateObject("VBScript.RegExp") With regEx .Global = True .Pattern = a tiqu = .Replace(str, "") End With End Function
3、创建完成后直接在excel中调用即可
说明:方法中i代表提取类型(1、提取字母;2、提取数字;3提取汉字)
小白技术分享