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 - 18 Mar 2008 23:44 GMT
dmalhotr2001@yahoo.com wrote in news:449748e9-9059-46ed-bd89-934318d6e7f9
@e6g2000prf.googlegroups.com:
> 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\_]*

Signature
spamhoneypot@rogers.com (Do not e-mail)
jamil@onepost.net - 19 Mar 2008 00:04 GMT
>Hi,
>
[quoted text clipped - 5 lines]
>
>: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 - 19 Mar 2008 12:20 GMT
On Mar 18, 4:08 pm, dmalhotr2...@yahoo.com wrote:
> Hi,
>
[quoted text clipped - 5 lines]
>
> :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]