Vbscript UFT:如何仅获取字段中的数字字符
如何使用getroproperty并捕获字段中的所有数字字符?例如: 地址字段:123测试街 提前感谢,,Vbscript UFT:如何仅获取字段中的数字字符,vbscript,qtp,Vbscript,Qtp,如何使用getroproperty并捕获字段中的所有数字字符?例如: 地址字段:123测试街 提前感谢,, P使用正则表达式从字符串中提取所有数字: str="123 test street" Set reg = New RegExp reg.Global=True reg.IgnoreCase=False reg.Pattern="\d+" Set mats = reg.Execute(str) For Each mat In mats MsgBox mat.Value
P
使用正则表达式从字符串中提取所有数字:
str="123 test street"
Set reg = New RegExp
reg.Global=True
reg.IgnoreCase=False
reg.Pattern="\d+"
Set mats = reg.Execute(str)
For Each mat In mats
MsgBox mat.Value 'You can store this required value in a variable and use it further
Next
或者,如果您确定字符串格式与共享的格式完全相同,则可以使用split方法获取该数组的第0项
str="123 test street"
requiredNumbers = split(str," ")(0)