473,700 Members | 2,616 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Strip all non alpha characters from a string

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 string that I tried tweaking without
success. Any help would be much appreciated.

Thanks in advance,
Mark C.
he******@yahoo. com
Nov 13 '05 #1
6 9088
Function StripAlphaChars (strOriginalStr ing As String) As String
Dim intLoop As Integer
Dim strTemp As String
strTemp = strOriginalStri ng
For intLoop = Asc("A") To Asc("Z")
strTemp = Replace(strTemp , Chr(intLoop), "", 1, -1, vbTextCompare)
Next intLoop
StripAlphaChars = strTemp
End Function

--

Ken Snell
<MS ACCESS MVP>

"Mark C" <he******@yahoo .com> wrote in message
news:4d******** ************@co mcast.com...
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 string that I tried tweaking without
success. Any help would be much appreciated.

Thanks in advance,
Mark C.
he******@yahoo. com

Nov 13 '05 #2
Oops -- Sorry, I misread your post. This will strip numeric characters from
the string. If you want to cover other alpha characters, such as French or
German alpha characters, you can modify the For loop parameters as needed.

Full "width" of ASCII characters is 0 to 255 for Chr(x) function (x = 0 to
255).
Function StripNumberChar s(strOriginalSt ring As String) As String
Dim intLoop As Integer
Dim strTemp As String
On Error Resume Next
strTemp = strOriginalStri ng
For intLoop = Asc("0") To Asc("9")
strTemp = Replace(strTemp , Chr(intLoop), "", 1, -1, vbTextCompare)
Next intLoop
StripNumberChar s = strTemp
Err.Clear
End Function

"Mark C" <he******@yahoo .com> wrote in message
news:4d******** ************@co mcast.com...
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 string that I tried tweaking without
success. Any help would be much appreciated.

Thanks in advance,
Mark C.
he******@yahoo. com

Nov 13 '05 #3
There are always, of course, lots of ways of doing these things. Here's
another approach (adapted from Ken's):
Function StripAlphaChars (strOriginalStr ing As String) As String
Dim intLoop As Integer
Dim strTemp As String
Dim strChar As String
strTemp = ""
For intLoop = 1 To Len(strOriginal String)
strChar = Mid$(strOrigina lString, intLoop, 1)
Select Case Asc(strChar)
' Upper case chars [A-Z]
Case 65 To 90: strTemp = strTemp & strChar
' Lower case chars [a-z]
Case 97 To 122: strTemp = strTemp & strChar
Case Else
End Select
Next intLoop
StripAlphaChars = strTemp
End Function

HTH,
Randy

"Ken Snell" <kt***********@ ncoomcastt.rena etl> wrote in message
news:up******** ******@TK2MSFTN GP09.phx.gbl...
Oops -- Sorry, I misread your post. This will strip numeric characters from the string. If you want to cover other alpha characters, such as French or
German alpha characters, you can modify the For loop parameters as needed.

Full "width" of ASCII characters is 0 to 255 for Chr(x) function (x = 0 to
255).
Function StripNumberChar s(strOriginalSt ring As String) As String
Dim intLoop As Integer
Dim strTemp As String
On Error Resume Next
strTemp = strOriginalStri ng
For intLoop = Asc("0") To Asc("9")
strTemp = Replace(strTemp , Chr(intLoop), "", 1, -1, vbTextCompare)
Next intLoop
StripNumberChar s = strTemp
Err.Clear
End Function

"Mark C" <he******@yahoo .com> wrote in message
news:4d******** ************@co mcast.com...
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 string that I tried tweaking without success. Any help would be much appreciated.

Thanks in advance,
Mark C.
he******@yahoo. com


Nov 13 '05 #4
Thanks ken, The function worked perfectly.

Regards,
Mark C.
he******@yahoo. com
"Ken Snell" <kt***********@ ncoomcastt.rena etl> wrote in message
news:up******** ******@TK2MSFTN GP09.phx.gbl...
Oops -- Sorry, I misread your post. This will strip numeric characters from the string. If you want to cover other alpha characters, such as French or
German alpha characters, you can modify the For loop parameters as needed.

Full "width" of ASCII characters is 0 to 255 for Chr(x) function (x = 0 to
255).
Function StripNumberChar s(strOriginalSt ring As String) As String
Dim intLoop As Integer
Dim strTemp As String
On Error Resume Next
strTemp = strOriginalStri ng
For intLoop = Asc("0") To Asc("9")
strTemp = Replace(strTemp , Chr(intLoop), "", 1, -1, vbTextCompare)
Next intLoop
StripNumberChar s = strTemp
Err.Clear
End Function

"Mark C" <he******@yahoo .com> wrote in message
news:4d******** ************@co mcast.com...
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 string that I tried tweaking without success. Any help would be much appreciated.

Thanks in advance,
Mark C.
he******@yahoo. com


Nov 13 '05 #5
You're welcome.

--

Ken Snell
<MS ACCESS MVP>

"Mark C" <he******@yahoo .com> wrote in message
news:k7******** ************@co mcast.com...
Thanks ken, The function worked perfectly.

Regards,
Mark C.
he******@yahoo. com
"Ken Snell" <kt***********@ ncoomcastt.rena etl> wrote in message
news:up******** ******@TK2MSFTN GP09.phx.gbl...
Oops -- Sorry, I misread your post. This will strip numeric characters

from
the string. If you want to cover other alpha characters, such as French or
German alpha characters, you can modify the For loop parameters as needed.
Full "width" of ASCII characters is 0 to 255 for Chr(x) function (x = 0 to 255).
Function StripNumberChar s(strOriginalSt ring As String) As String
Dim intLoop As Integer
Dim strTemp As String
On Error Resume Next
strTemp = strOriginalStri ng
For intLoop = Asc("0") To Asc("9")
strTemp = Replace(strTemp , Chr(intLoop), "", 1, -1, vbTextCompare)
Next intLoop
StripNumberChar s = strTemp
Err.Clear
End Function

"Mark C" <he******@yahoo .com> wrote in message
news:4d******** ************@co mcast.com...
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 string that I tried tweaking without success. Any help would be much appreciated.

Thanks in advance,
Mark C.
he******@yahoo. com



Nov 13 '05 #6
> > "Mark C" <he******@yahoo .com> wrote in message
news:4d******** ************@co mcast.com...
All,

Is there such a function that can strip all non alpha ( not between a-z)

Guess I misunderstood. I thought that meant that you might want to strip
characters besides digits, such as punctuation and control characters, as
well.
characters from a string? I have a function that I currently use that will strip one character at a time from a string that I tried tweaking without success. Any help would be much appreciated.

Thanks in advance,
Mark C.
he******@yahoo. com


Nov 13 '05 #7

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

Similar topics

7
6218
by: jason | last post by:
How would I strip out everything from before the last "/" in the following string generated from request.servervaraibles method: http://www.essermanyachtsales.com/riverbend/ ....so that I was just left with: "Riverbend" Many thanks
2
24194
by: Giampiero Gabbiani | last post by:
Hi to all, Is there a simple way to implement a strip algorithm on std::string using STL? I'm sure that it's possible to implement it using some transform, but my knowledge of STL is POOR. Regards Giampiero
22
13761
by: ineedyourluvin1 | last post by:
Hello all! I've been looking for a way to strip characters from strings such as a comma. This would be great for using a comma as a delimiter. I show you what I have right now. #include<iostream> #include<string> int main(int argc, char *argv) {
6
1861
by: Steve Bergman | last post by:
When sanitizing data coming in from HTML forms, I'm doing this (lifted from the Python Cookbook): from string import maketrans, translate, printable allchars = maketrans('','') delchars = translate(allchars, allchars, printable) input_string = translate(input_string, allchars, delchars) Which is OK. But it seems like there should be more straightforward way that I just haven't figured out. Is there?
5
4926
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 change depending on the month, "05001" is the year "05" and "001" a sequential increment. I Know how to get "CR?05001" but I'm stuck on trying to convert the month number to the alpha characters. Any suggestions? Thanks in advance. This is a...
4
11416
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 (regExp.IsMatch( Value.ToString() )) { return true; }
4
3313
by: David Beck | last post by:
I donwnload some files for processing every day that have unwanted characters in them. In VB6 I use the InputB to read in the text and the StrConv. vLinesFromFile = StrConv(InputB(LOF(nFileNumGENERIC), nFileNumGENERIC), vbUnicode) If the string has any unwanted characters (e.g. Chr(26)), I use the replace to remove them and save the file.
2
16891
by: Brian Henry | last post by:
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!
2
2760
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 embedded in that string that tells me stuff that I need to know). However, when a customer tries to use an IVR or web site to self service (a tracking enquiry) the number is way too long and prone to error when being entered via DTMF, Speech recognition...
0
8714
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8641
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9203
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8912
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7797
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6557
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5897
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4396
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4650
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.