regular expression

  • Thread starter Thread starter flagisup
  • Start date Start date
F

flagisup

Having difficulty coming up with a regular expression that
would cover the following criteria.

1. five characters in length
2. at least one of the five characters has to be [a-z]
3. at least one of the five characters has to be [0-9]

thanks
 
So am I, off the top of my head, though I'm sure it can be done with
backreferences or something. Can you use

Like "?????" And Like "*[0-9a-z]*"

instead?

Having difficulty coming up with a regular expression that
would cover the following criteria.

1. five characters in length
2. at least one of the five characters has to be [a-z]
3. at least one of the five characters has to be [0-9]

thanks
 
John, I think you need to modify that slightly to meet all three conditions.

Like "?????" And Like "*[a-z]*" And Like "*#*"

I don't know how to do it as a regular expression.

John said:
So am I, off the top of my head, though I'm sure it can be done with
backreferences or something. Can you use

Like "?????" And Like "*[0-9a-z]*"

instead?

Having difficulty coming up with a regular expression that
would cover the following criteria.

1. five characters in length
2. at least one of the five characters has to be [a-z]
3. at least one of the five characters has to be [0-9]

thanks
 
Hi John,

You're right: I misread the OP and ORed when I should have ANDed.

As for the regex, I spent a few minutes on it and ended up using two
lookahead assertions to check the letter and number were there. I used
Perl 5.6 and tested it cursorily with this:

perl -ne"print qq(OK\n) if m/^(?=.*\d)(?=.*[A-Z]).{5}$/i"

I think it will work with the VBScript 5.5 regular expression object; it
would be something like
.ignorecase = -1
.pattern = "^(?=.*\d)(?=.*[A-Z]).{5}$"

If no characters other than letters and numbers are allowed, replace the
last "." with "[0-9A-Z]".

John, I think you need to modify that slightly to meet all three conditions.

Like "?????" And Like "*[a-z]*" And Like "*#*"

I don't know how to do it as a regular expression.

John said:
So am I, off the top of my head, though I'm sure it can be done with
backreferences or something. Can you use

Like "?????" And Like "*[0-9a-z]*"

instead?

Having difficulty coming up with a regular expression that
would cover the following criteria.

1. five characters in length
2. at least one of the five characters has to be [a-z]
3. at least one of the five characters has to be [0-9]

thanks
 
Back
Top