[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

C#, Pulling only numeric values from a string

Posted on 2007-10-01
4
Medium Priority
?
414 Views
Last Modified: 2013-12-17
I am trying to pull only the number values from a string.  They will always start with a string and end in a numbers.

i.e ABC213
I only want to get the 213.

Thanks
0
Comment
Question by:vandy02
  • 2
3 Comments
 
LVL 58

Accepted Solution

by:
amit_g earned 1000 total points
ID: 19995187
yourNumericString = System.Text.RegularExpressions.Regex.Replace(yourString, "[^0-9]", "");
0
 
LVL 8

Expert Comment

by:sjturner2
ID: 20017900
This will give you the numbers in a string, use Double.Parse or Int.Parse to convert this string into a double/int.
0
 
LVL 58

Expert Comment

by:amit_g
ID: 20150504
Regex.Replace would do what was asked. So I would recommend a PAQ.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

873 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