1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > Excel-VBA:根据正则表达式提取文本(字符串 内容)

Excel-VBA:根据正则表达式提取文本(字符串 内容)

时间:2020-01-15 16:11:17

相关推荐

Excel-VBA:根据正则表达式提取文本(字符串 内容)

'测试:将“abc@@eee”中的@@提取出来Sub test()MsgBox GetValueByRegex("abc@@eee", "abc(.*?)eee")End SubFunction GetValueByRegex(ByVal OrgStr As String, ByVal PatternStr As String)Set re = CreateObject("VBScript.RegExp")re.Pattern = PatternStrre.Global = Truere.IgnoreCase = FalseSet matchs = re.Execute(OrgStr)If matchs.Count > 0 ThenGetValueByRegex = matchs(0).submatches(0)ElseGetValueByRegex = ""End IfEnd Function

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。