如何在VBA Excel中使用多个分隔符分割字符串? [英] How to split a string with multiple delimiters in vba excel?
本文介绍了如何在VBA Excel中使用多个分隔符分割字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用Excel VBA分割带有多个定界符的字符串.字符串之一是:
I want to split a string with multiple delimiters using Excel VBA. One of the strings is:
d1-d2 d3 d4
我们有一个破折号和一个空格作为两个定界符.我尝试了split
函数,但仅使用一个定界符来实现.
We have a dash and a space as two delimiters. I tried the split
function but it only does it with one delimiter.
推荐答案
您可以先在字符串上先执行Replace
,然后再进行拆分:
You could first do a Replace
on the string first and then do the split:
newString = Replace(origString, "-", " ")
newArray = Split(newString, " ")
这篇关于如何在VBA Excel中使用多个分隔符分割字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文