Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Strip characters from number

Posted on 2004-04-14
3
242 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
ID: 10824191
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
ID: 10824543
Hi KaiserSose,

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

Esteban Felipe
www.estebanf.com
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

839 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