Skip navigation

How can I use VBScript to extract all numeric characters from a string?

A. The following script, which you can download at http://www.windowsitpro.com/articles/download/extractnum.zip , takes a passed string and outputs only the numeric characters:

Option Explicit

Dim strOriginal, intLength, intCount, strFinal

' Check all arguments required have been passed
If Wscript.Arguments.Count 

The following sample execution
D:\temp>cscript extractnumeric.vbs 1234sd242ds--34..df
Would produce this result:
123424234

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish