Asp.net Forum

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds

Regular expression

  Asked By: Juana    Date: Jan 08    Category: Asp.net    Views: 795

i'm trying to make a regular expression for an input-field of a winform.
I wanna force the user to enter strings, so not started with a number...
But my regex doesn't work...
Somebody sees what i'm doing wrong?

dim myRegEx As regex
myRegEx = New Regex("^(\d)*(\w)")

Dim match As Match = myRegEx.Match(gegevens)
If (match.Success) Then
End If



3 Answers Found

Answer #1    Answered By: Becky Baker     Answered On: Jan 08

give this regex a shot:

myRegEx = New Regex("^[^\d*](\w)*")

you need to put the [^\d*] in there to tell it that you don't want digits to
start out with. it'll let digits pass through after the first nondigit

Answer #2    Answered By: Stacie Martin     Answered On: Jan 08

I think that regex is a bit off. It says that the string can't start
with a digit OR a *. If the string can start with ANYTHING but a digit
you can use:


If it MUST start with an alphabetic character, you can use:


Check out the following link for more on regular  expressions:

Answer #3    Answered By: Adali Fischer     Answered On: Jan 08

I have been searching a lot for a regular  expression that validates a
user's input.
The input can be anything but not just numbers alone.

There can be numbers and any special characters in the input along with
other alphabets but I should not allow the user  to enter  just numbers or
special characters without any alphabets.

Can anyone help me with this??

Didn't find what you were looking for? Find more on Regular expression Or get search suggestion and latest updates.