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

A. The following script, which you can download at , 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:

Hide 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.