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

John Savill

August 20, 2006

1 Min Read
ITPro Today logo in a gray background | ITPro Today

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 ExplicitDim strOriginal, intLength, intCount, strFinal' Check all arguments required have been passedIf Wscript.Arguments.Count 

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

About the Author

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like