标记字符串
我有大约 100 行想要标记的文本,它们类似于以下内容:
<word> <unknown number of spaces and tabs> <number>
我在使用 VBA 查找标记化函数时遇到问题。 在 VBA 中标记此类字符串的最简单方法是什么?
I have around 100 rows of text that I want to tokenize, which are alike the following:
<word> <unknown number of spaces and tabs> <number>
I am having trouble finding tokenize functions with VBA. What would be the easiest method to tokenize such strings in VBA?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用
Split()
方法,或者对于更复杂的匹配,您可以使用"vbscript.regexp"
对象:以下是有关在 VBA 中使用正则表达式的教程:在 Excel 中使用正则表达式 (RegExp)
You can use the
Split()
method or for more complex matches, you can use the"vbscript.regexp"
object:Here's a tutorial on using regex from VBA: Using Regular Expressions (RegExp) in Excel
您可以逐行阅读并使用 split 函数按空格分割单词和数字。 我依稀记得VBA有split功能。
我通过谷歌搜索得到了以下链接。 不确定您使用的是哪个版本的 Office。
http://msdn.microsoft.com/en-us /library/aa155763(office.10).aspx
该链接具有分割功能。
You could read line by line and use the split function to split the word and number by space. I vaguely remeber VBA has the split function.
I got the following link by searching in google. Not sure which version of office you are using.
http://msdn.microsoft.com/en-us/library/aa155763(office.10).aspx
This link has the split function.
直接从 MS 页面
http://msdn.VBA 拆分功能microsoft.com/en-us/library/aa155763(office.10).aspx
VBA split function right from MS's page
http://msdn.microsoft.com/en-us/library/aa155763(office.10).aspx