Using Regular Expression Validation

C

Coleen

I can't remember the correct way to write a custom regular expression validator, and the help file for VB.net is not terribly helpful...it does not give any real world examples. I've got the main syntax of ^[a-zA-z] but I can't remember how to write the next portion. I need to validate passwords...they must start with a letter of the alphabet, can contain 0-9 and can contain the special characters @#$%&, I just can't remember the correct syntax to write this as a regular expression validation.
Is it ^[a-zA-z]|[a-zA-Z0-9@#$%&] ? I'm not certain about the special characters, they can be in any order as long as the first character is a letter.

Any help/suggestions are greatly appreciated.

TIA, Coleen
 
P

Peter Blum

That looks very good for someone who cannot remember Regexes :)

Here's a resource I like for figuring out regexes:
http://devedge.netscape.com/library/manuals/2000/javascript/1.5/reference/regexp.html#1193136

The only question I would have is whether you have a minimum size. In that
case, replace the ? with a {min, max} like {4, 20}.

Also add the '$' to the end.

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

I can't remember the correct way to write a custom regular expression
validator, and the help file for VB.net is not terribly helpful...it does
not give any real world examples. I've got the main syntax of ^[a-zA-z] but
I can't remember how to write the next portion. I need to validate
passwords...they must start with a letter of the alphabet, can contain 0-9
and can contain the special characters @#$%&, I just can't remember the
correct syntax to write this as a regular expression validation.
Is it ^[a-zA-z]|[a-zA-Z0-9@#$%&] ? I'm not certain about the special
characters, they can be in any order as long as the first character is a
letter.
Any help/suggestions are greatly appreciated.

TIA, Coleen
engine supports Post Alerts, Ratings, and Searching.
 
C

Coleen

Thanks :) I took it in class, but it's been months since I've used it, so
I'm not certain it will do everything I need. I do need to check it for
length, thanks very much for the suggestion and link. I appreciate it :)
Peter Blum said:
That looks very good for someone who cannot remember Regexes :)

Here's a resource I like for figuring out regexes:
http://devedge.netscape.com/library/manuals/2000/javascript/1.5/reference/regexp.html#1193136

The only question I would have is whether you have a minimum size. In that
case, replace the ? with a {min, max} like {4, 20}.

Also add the '$' to the end.

--- Peter Blum
www.PeterBlum.com
Email: (e-mail address removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

I can't remember the correct way to write a custom regular expression
validator, and the help file for VB.net is not terribly helpful...it does
not give any real world examples. I've got the main syntax of ^[a-zA-z] but
I can't remember how to write the next portion. I need to validate
passwords...they must start with a letter of the alphabet, can contain 0-9
and can contain the special characters @#$%&, I just can't remember the
correct syntax to write this as a regular expression validation.
Is it ^[a-zA-z]|[a-zA-Z0-9@#$%&] ? I'm not certain about the special
characters, they can be in any order as long as the first character is a
letter.
Any help/suggestions are greatly appreciated.

TIA, Coleen
engine supports Post Alerts, Ratings, and Searching.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Regular expression syntax error 1
Regular expression problem 13
RegEx 0
Regular Expression 1
Regular Expression 3
Regular Expression question 4
Validation Expression 2
Validation expression 2

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top