Search: | |||||

| ||||

Home » Forum » Asp.net | RSS Feeds |

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

...

doaction

...

Else

errormessage

End If

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

char.

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:

[^0-9].*

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

[a-zA-Z].*

Check out the following link for more on regular expressions:

www.4guysfromrolla.com/.../...larExpressions.shtml

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.

Related Topics:

- Regular expressions
- regular expression object in java
- Regular expression help
- Can we Use Excel as a regular database?
- calculating area of a regular polygon
- Converting Expression from postfix to infix
- AND - Only two expressions
- Binary tree for algebraic expression
- Increment & Decrement Operator in Expressions