Retrieve only numbers and ignore alphabets from String

0
0

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?

  • You must to post comments
0
0

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
  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Website