WelcomeServicesPortfolioKnowledge BaseContact Us
27 Seconds, Inc.


Knowledge base View Article

need hosting?

Need hosting? We use and love our host - CrystalTech.com!
Need hosting? We use and love our host - CrystalTech.com!

Text Disguise - CAPTCHA-image/Human Interactive Proof web services

National Holiday Dates and Bank Holiday Dates - web site that provides the dates of national and bank holidays for the United States, United Kingdom, Ireland and Scotland

Holiday Web Service - web services for programmers to provide the dates of national and bank holidays in their applications for the United States, United Kingdom, Ireland and Scotland

Our Family Heart - web site to help families communicate no matter where they are

What?! You haven't heard about the greatest remote controlled flyer to come out in years?! Checkout the FlyTech DragonFly now!

Strip non-numeric characters using ASP

Summary: Strip non-numeric characters using ASP and Regular Expressions.
 
Keywords: ASP
EXPRESSION
NUMBER
NUMERIC
REG
REGEXP
REGULAR
REGULAR EXPRESSIONS
Applicable Software: Active Server Pages (ASP)
 
Body:

One of the best thing things you can do, when programming, is validate user input. This can save you all kinds of headache in the long run - problems with database inserts/updates, problem with SQL Injection, problems with variables types not being what you expect.

In this article, I am going to show you how to take a string and return just the numbers from it. Stripping all alphabetical and symbols from it.

Function StripAlphaChars(ByVal pstrSource)
Dim m_strOut
	m_strOut = Trim(pstrSource & "")
Dim m_objReg
	Set m_objReg = New RegExp

		m_objReg.Pattern = "\D"
		m_objReg.Global = True
		m_objReg.IgnoreCase = True
		'm_objReg.MultiLine = True

		m_strOut = m_objReg.Replace(m_strOut, "")

	Set m_objReg = Nothing

	StripAlphaChars = m_strOut

End Function

 
Author: Douglas L. Setzer, II, http://www.27seconds.com
Posted On: 6/4/2002 8:00:37 AM

Rate this article: Average: 8.6
n/a12345678910
Comments?

Article Search   |   All Articles

 

 
©2002 27 Seconds, Inc. All Rights Reserved.