473,385 Members | 1,927 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

removing alpha characters from string

Is there any quick and easy (other then scanning a string char by char) to
remove all the alpha chars from a string and leave only numbers?

ex:

A12334234-3431AP

comes out to 123342343431
thanks!
Nov 21 '05 #1
2 16856
"Brian Henry" <no****@nospam.com> schrieb:
Is there any quick and easy (other then scanning a string char by char) to
remove all the alpha chars from a string and leave only numbers?

ex:

A12334234-3431AP

comes out to 123342343431


\\\
Imports System.Text.RegularExpressions
..
..
..
Dim s As String = "A23zb4-u98"
MsgBox(Regex.Replace(s, "[^0-9]", ""))
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #2
just use a regex that extracts only the numbers?

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Brian Henry" <no****@nospam.com> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
Is there any quick and easy (other then scanning a string char by char) to
remove all the alpha chars from a string and leave only numbers?

ex:

A12334234-3431AP

comes out to 123342343431
thanks!

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Amit Varia | last post by:
How would you remove newline characters from a string? I tried str_replace("\n", "", $string); But that doesn't work.
6
by: Mark C | last post by:
All, Is there such a function that can strip all non alpha ( not between a-z) characters from a string? I have a function that I currently use that will strip one character at a time from a...
5
by: PCV | last post by:
Hi All, I want to create a custom auto number in a form that looks like "CRA05001" where "CR" are fixed characters, then "A" should be for January as "B" for February and so on...(this part will...
6
by: becte | last post by:
I am little bit confused Is this a legal way of removing a substring from a string? What about the second alternative using strcpy, is it ok even though the source and dest. strings overlap? ...
4
by: Tim Conner | last post by:
I wrote the following function to test a string for characters from a to z and the "_" character : public static bool IsAlpha( char Value ) { Regex regExp = new Regex("^*$"); if...
6
by: bruce | last post by:
hi... i'm running into a problem where i'm seeing non-ascii chars in the parsing i'm doing. in looking through various docs, i can't find functions to remove/restrict strings to valid ascii...
0
by: Benny the Guard | last post by:
I have a string value that may contain some unprintable characters. I am using the xml.sax.escape to remove the the <, > and & characters fine but it seems to leave in the \n characters. Later this...
8
by: Betray | last post by:
i have a table that lets say has 3 fields ID, NAME, SEARCHFIELD name can take any character, while searchfield only has the alpha/num characters from name. (eg name: Swine-?6$Man...
2
by: Andrew Sweney | last post by:
I have a system that generates a 24ch alpha-numeric string as a tracking number. An example looks like this - 1898240001631501AKL003HS. This is great for what it does (there is information...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.