|
本帖最后由 laoau138 于 2017-6-15 16:08 编辑
用VBA正则把一句英文拆分成几个单词
第一次发问正则,高手快来解答
- Sub aaa()
- Dim arr, i&, reg As Object, match, matches, c&
- arr = Range([a1], [a65536].End(3))
- Set reg = CreateObject("vbscript.regexp")
- With reg
- .Global = True
- .Pattern = "[a-zA-Z]+"
- For i = 1 To UBound(arr)
- c = 1
- Set matches = reg.Execute(arr(i, 1))
- For Each match In matches
- c = c + 1
- Cells(i, c) = match
- Next
- Next i
- End With
- End Sub
复制代码
|
|