Solved

Strip characters from number

Posted on 2004-04-14
3
236 Views
Last Modified: 2010-04-15
Hi, I want the user to be able to enter any form of number in my price textbox and I will automatically strip anything that is not an integer.

I obviously can't mand a string.replace for every character, so is there a way to use a regexp to say anything that isnt 0-9?

This will match any unsigned integer:   ^\d*$     So is there a way to say   if(! ^\d*$)?

Thanks, Dave
0
Comment
Question by:KaiserSose
3 Comments
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 125 total points
Comment Utility
you could just say .ToCharArray() and then use if char >= '0' && char <= '9' to determine if its numeric ...

or you could just use Char.IsNumber()
0
 
LVL 12

Assisted Solution

by:esteban_felipe
esteban_felipe earned 125 total points
Comment Utility
Hi KaiserSose,

string result = Regex.Replace(input,"\\d",String.Empty)

Esteban Felipe
www.estebanf.com
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now