473,508 Members | 2,363 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

only letters or numbers

hey all,

given a string, if i only wanted to get only letters and number (no symbols)
is there a function to do this?
i.e.
"Los Angeles, CA"
i don't want the comma.

thanks,
rodchar
Mar 26 '06 #1
3 12082

"rodchar" <ro*****@discussions.microsoft.com> wrote in message
news:7E**********************************@microsof t.com...
given a string, if i only wanted to get only letters and number (no
symbols)
is there a function to do this?
i.e.
"Los Angeles, CA"
i don't want the comma.


Function CleanInput(strIn As String) As String
' Replace invalid characters with empty strings.
Return Regex.Replace(strIn, "[^\w\.@-]", "")
End Function

You can use
Return Regex.Replace(strIn, ",", "")
if that's all you need.
Mar 27 '06 #2
The easy way:

Dim s as string = strIn.Replace(",", "")

or the relatively easy way:

Dim strOut as string = ""
for each c as char in strIn.ToCharArray()
if char.IsLetterOrDigit(c) then
strOut &= c.ToString()
end if
next.

Either way, YOU WIN!

SN

Mar 27 '06 #3
Hi,

Use a regular expression.

Dim regText As New System.Text.RegularExpressions.Regex("^[a-zA-Z0-9]+$ ")

Trace.WriteLine(regText.IsMatch("Los Angeles, CA"))


http://regexlib.com/Search.aspx?k=alphanumeric

Ken
---------------
"rodchar" <ro*****@discussions.microsoft.com> wrote in message
news:7E**********************************@microsof t.com...
hey all,

given a string, if i only wanted to get only letters and number (no
symbols)
is there a function to do this?
i.e.
"Los Angeles, CA"
i don't want the comma.

thanks,
rodchar

Mar 27 '06 #4

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

Similar topics

4
8973
by: Sugapablo | last post by:
Does anyone have a handy-dandy function they can quickly post that strips everything from a string except for letters, numbers, & underscores? -- http://www.sugapablo.com <--music ]...
1
2134
by: jel | last post by:
I ran what was submitted in several forums, but it's not exactly what i'm looking for. I'm dy'n over here. Ah, the frustrations of an amateur programmer. I included the code below in c++. which...
7
2119
by: stevenkobes | last post by:
A lot of websites have forms with an image at the bottom containing some distorted / noisy letters and numbers that users must type in to prove they are real people. How do they normally implement...
4
1861
by: techcs | last post by:
Hi, Wondering if anyine can help with the membership PHP script I lifted from a tutorial. I'm new to PHP and have this system up and running but my password only come out at three letters and...
1
5430
by: Kosmos | last post by:
Since people have been so helpful on this site I thought I'd contribute what little I can...since I am not a programmer but I'm working on an access database for work Anyways I had to remove...
1
3124
by: Jeff | last post by:
hey gang. I have a code to create a random string of letters. The number of them can be whatever I desire. what i would like to do, is have it both letters and integers. how would i modify...
2
1766
by: dpreston74 | last post by:
Hello forum. I need to learn how write a SQL script to strip 0s from data and strip alpha letters from alpha numeric data. e.g. I get data like 054, 006, 903, for a dept number. I need to...
6
1931
by: Josh Mitchell | last post by:
Hello, Could anyone direct me to some sample script that makes a div or text visible only when a webform field in selected. So for example, in the below snippet, I want the text "Your username...
3
6626
by: sasimca007 | last post by:
Hello friends, We have seen many textboxes, it is used as date,readonly,text etc... If we want to restrict the textbox with not to enter letters only numbers and one more...
2
2866
Thekid
by: Thekid | last post by:
I had made a post about making a loop using letters instead of numbers and dshimer gave me this solution: for i in range(65,70): for j in range(65,70): for k in range(65,70): ...
0
7115
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...
0
7377
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...
1
7036
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7489
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...
0
4705
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...
0
3191
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...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
414
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.