Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regular expressions

Status
Not open for further replies.

BoostMR2

IS-IT--Management
Jul 20, 2007
33
0
0
US
I have some simple code that checks a string for lowercase charatcers. I then want to know how many lowercase characters exist. Later in the code I also check for other regulkar expression filters such as uppercase, numbers, and special characters. For simplicity, I am only showing lowercase.

Const PASSWORD_LOWERCASE_FILTER = "[a-z]"

Dim strString
Dim objRegExp


strString = "aaaabbbbAAAABBBB"

Set objRegExp = New RegExp
objRegExp.Pattern = PASSWORD_LOWERCASE_FILTER
objRegExp.IgnoreCase = False
objRegExp.Global = False

Set expressionmatch = objRegExp.Execute(strString)

if expressionmatch.Count => 2 then
msgbox(expressionmatch.Count)
end if

No matter what that string is, expressionmatch.Count is always equal to either 0 or 1, which doesn't make sense. I expected it to equal 8, since there are 4 lowercase a's and 4 lowercase b's. Any ideas?

Note: I do know a workaround, which is to use:
dim count
for each match in expressionmatch
count = count + 1

But if .count is supposed to work (which according to documentation, it is) I want to find out why it doesn't here
 
>objRegExp.Global = False
[tt]objRegExp.Global = [red]True[/red][/tt]
 
That did the trick, I appreciate it. This was my first attempt at reg expressions. I'm using this to validate secure passwords from a website, such as 3 special charatcers, etc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top