Regular Expression Help?

  • Thread starter Thread starter Vagabond Software
  • Start date Start date
V

Vagabond Software

I'm trying to validate a text box that complies with the following rules:

1) text can be blank/empty
2) non-blank text shall contain ONLY A-Z and/or 0-9
3) non-blank text shall contain a maximum of 6 characters

Here is what I have so far...

(^A-Z0-9*$){0,6}

Don't look at it too long because it is not working as desired and will only
throw you off the trail. Any help is greatly appreciated.

carl
 
Vagabond said:
I'm trying to validate a text box that complies with the following rules:

1) text can be blank/empty
2) non-blank text shall contain ONLY A-Z and/or 0-9
3) non-blank text shall contain a maximum of 6 characters

Here is what I have so far...

(^A-Z0-9*$){0,6}

@"^[A-Z0-9]{0,6}$"
 
I'm trying to validate a text box that complies with the following
rules:
1) text can be blank/empty
2) non-blank text shall contain ONLY A-Z and/or 0-9
3) non-blank text shall contain a maximum of 6 characters

Here is what I have so far...

(^A-Z0-9*$){0,6}

@"^[A-Z0-9]{0,6}$"

I think you may want a space in there, if by rule one, you allow spaces:
(A-Z0-9 ){0,6}

If you only allow 6 chars, you may want to first grab a substring of the
first six chars and then apply this validation. I'm not sure by your rules
whether you need the beginning and end of string anchors....
 

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 4
Regular Expressions 4
Regular Expression Help 2
Obfuscate 4
regular expression 7
Regular Expression Help 1
Are you a RegEx bandido? 2
Regular expressions 3

Back
Top