问题描述
我有 6400 多条记录在循环中.对于这些中的每一个:我通过针对类似于邮局使用的内容(查找地址)进行测试来检查地址是否有效.我需要仔细检查我撤回的邮政编码是否匹配.
I have 6400+ records which I am looping through. For each of these: I check that the address is valid by testing it against something similar to what the Post Office uses (find address). I need to double check that the postcode I have pulled back matches.
唯一的问题是邮政编码可能以多种不同的格式输入,例如:
The only problem is that the postcode may have been inputted in a number of different formats for example:
OP6 6YH
OP66YH
OP6 6YH.
If Replace(strPostcode," ","") = Replace(xmlAddress.selectSingleNode("//postcode").text," ","") Then
If Replace(strPostcode," ","") = Replace(xmlAddress.selectSingleNode("//postcode").text," ","") Then
我想从字符串中删除所有空格.如果我执行上面的替换,它会删除第一个示例的空间,但为第三个示例保留一个空间.
I want to remove all spaces from the string. If I do the Replace above, it removes the space for the first example but leave one for the third.
我知道我可以使用循环语句删除这些,但相信这会使脚本运行非常缓慢,因为它必须循环遍历 6400 多条记录才能删除空格.
I know that I can remove these using a loop statement, but believe this will make the script run really slow as it will have to loop through 6400+ records to remove the spaces.
还有别的办法吗?
推荐答案
我没有意识到您必须添加 -1 才能删除所有空格
I didn't realise you had to add -1 to remove all spaces
Replace(strPostcode," ","",1,-1)
这篇关于vbscript - 替换所有空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!