364,112 Members | 2160 Browsing Online
Community for Developers & IT Professionals
Bytes IT Community

removing alpha characters from string

Brian Henry
P: n/a
Brian Henry
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
Share this Question
Share on Google+
2 Replies


Herfried K. Wagner [MVP]
P: n/a
Herfried K. Wagner [MVP]
"Brian Henry" <nospam@nospam.com> schrieb:[color=blue]
> 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[/color]

\\\
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

Nick Malik [Microsoft]
P: n/a
Nick Malik [Microsoft]
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" <nospam@nospam.com> wrote in message
news:%2333SWXL%23EHA.2984@TK2MSFTNGP09.phx.gbl...[color=blue]
> 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!
>
>[/color]


Nov 21 '05 #3

Post your reply

Help answer this question



Didn't find the answer to your Visual Basic .NET question?

You can also browse similar questions: Visual Basic .NET