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提取汉字)
标签:Function,regEx,提取,自定义,excel,Excel,汉字,str,End 来源: https://www.cnblogs.com/liangyy09/p/16291382.html