Connecting Tech Pros Worldwide Forums | Help | Site Map

Regular expression problem

dmalhotr2001@yahoo.com
Guest
 
Posts: n/a
#1: Mar 18 '08
Hi,

I would like to know how to write regular expression in vb.net that
would be valid for a piece of text that is only numbers, letters,
dashes, and underscores that is allowed.

Thanks

:D

Spam Catcher
Guest
 
Posts: n/a
#2: Mar 18 '08

re: Regular expression problem


dmalhotr2001@yahoo.com wrote in news:449748e9-9059-46ed-bd89-934318d6e7f9
@e6g2000prf.googlegroups.com:
Quote:
Hi,
>
I would like to know how to write regular expression in vb.net that
would be valid for a piece of text that is only numbers, letters,
dashes, and underscores that is allowed.

[A-Za-z0-9\_]*


--
spamhoneypot@rogers.com (Do not e-mail)
jamil@onepost.net
Guest
 
Posts: n/a
#3: Mar 19 '08

re: Regular expression problem


On Tue, 18 Mar 2008 13:08:02 -0700 (PDT), dmalhotr2001@yahoo.com
wrote:
Quote:
>Hi,
>
>I would like to know how to write regular expression in vb.net that
>would be valid for a piece of text that is only numbers, letters,
>dashes, and underscores that is allowed.
>
>Thanks
>
>:D
The following expression will do what you requested:

^(?:\w|-)+$

This will match text containing numbers, letters, underscores and
dashes. If any other characters exist in the string, it will not
match.

If you want partial matches in your string, remove the two anchors as
follows:

(?:\w|-)+

To actually learn how I created that, there are a few books explaining
regular expressions. I like Friedl's book Master Regular Expressions.
rowe_newsgroups
Guest
 
Posts: n/a
#4: Mar 19 '08

re: Regular expression problem


On Mar 18, 4:08 pm, dmalhotr2...@yahoo.com wrote:
Quote:
Hi,
>
I would like to know how to write regular expression in vb.net that
would be valid for a piece of text that is only numbers, letters,
dashes, and underscores that is allowed.
>
Thanks
>
:D
One extremely useful resource for composing regular expressions is
Expresso. It's helps me out a ton whenever I have to use Regex.

Check it out at:

http://www.ultrapico.com/Expresso.htm

Thanks,

Seth Rowe [MVP]
Closed Thread