Evaluate if a string is uppercase in classic ASP (vbScript) v2

Hi.
An expert kindly helped me with this task this morning, however I'm finding an issue.
In the code below if targetString is "HELLO" then it works perfectly... However if

targetString = "HeLLO"

TRUE is also still produced and it should be FLASE?

Any Ideas?
<%
Dim re, targetString
Set re = New RegExp
With re
  .Pattern = "^[A-Z].*$"
  .Global = True
  .IgnoreCase = Flase
End With
targetString = "HeLLO"
 
response.write (re.Test(targetString))
%>

Open in new window

LVL 1
TheAnvilGroupAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ChetOS82Commented:
Your regular expression looks good, so I don't know why it doesn't work.  That being said, I wouldn't have used this method to determine if the string is uppercase.

In VBScript, string comparison is already case-sensitive.  So I just do:
<%
dim targetString
targetString = "HeLLO"
response.write (targetString = UCASE(targetString))
%>

Open in new window

0
ChetOS82Commented:
Ok, the reason this isn't working is because your pattern includes a period, which is essentially asking "Is the first letter uppercase, followed by any number of characters".

You need to remove the period from the pattern.
0
ChetOS82Commented:
Sorry about the triple post :)

That period is also causing the regexp to match numbers and special characters as well.  A targetString of "He1|0" would also evaluation to true.
0
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

David LeeCommented:
Hi, TheAnvilGroup.

I'm not much into regular expressions, so I'm not sure whey that code isn't working.  However, but we can test if the string is all uppercase in a much simpler fashion.
Dim strTest
strTest = "HeLLO"
response.write (UCase(strTest) = strTest)

Open in new window

0
David LeeCommented:
Ignore my post.  I refreshed the question before posting and there were no comments at all.  Then I post and asll the otehr comments appear.
0
aherpsCommented:

<%
Dim re, targetString
Set re = New RegExp
With re
  .Pattern = "^[A-Z]*$"
  .Global = True
  .IgnoreCase = Flase
End With
targetString = "HeLLO"
 
response.write (re.Test(targetString))
%>

Open in new window

0
hieloCommented:
two things:
1. >>.Pattern = "^[A-Z].*$"
get rid of the perios

2. .IgnoreCase = Flase
should be False
0
hieloCommented:
correction, the correct pattern is:
  .Pattern = "^[A-Z]+$"

if you leave
.Pattern = "^[A-Z]*$"

and then supply this:
targetString = ""

it will evaluate to true, which is not what you want. Use:
  .Pattern = "^[A-Z]+$"
0
hieloCommented:
In case you missed it, the pattern should be using a + symbol, NOT a *
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hieloCommented:
glad to help
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.