Retrieve only numbers and ignore alphabets from String

♀尐吖头ヾ 提交于 2019-12-20 03:07:22

问题


I have strings like 10A or 20B. I want 10 in 10A or 20 in 20B. How to split only numbers from string using VBScript or QTP internal commands?


回答1:


I would use a regular expression:

s = "20B"

Set re = New RegExp
re.Pattern = "^\d+"

For Each m In re.Execute(s)
  num = CInt(m)
Next

WScript.Echo num


来源:https://stackoverflow.com/questions/39601885/retrieve-only-numbers-and-ignore-alphabets-from-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!