Link to home
Start Free TrialLog in
Avatar of TheAnvilGroup
TheAnvilGroupFlag for United Kingdom of Great Britain and Northern Ireland

asked on

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

In classic ASP (using VBScript) I need to evaluate a string and determine if it's all uppercase.
Does anyone know if this is possible in ASP?
Avatar of aherps
aherps
Flag of Australia image

Dim re, targetString
Set rs = New RegExp
With re
  .Pattern = "^[A-Z].*$"
  .Global = False
  .IgnoreCase = False
End With
targetString = "HELLO"

re.Test(targetString) 'returns true or false - true in this case
Avatar of TheAnvilGroup

ASKER

Hi.
This does not seem to work?

The following error is shown...

----
Microsoft VBScript runtime  error '800a01a8'
Object required: '[undefined]'
----

Here is the code used:

<%
Dim re, targetString
Set rs = New RegExp
With re
  .Pattern = "^[A-Z].*$"
  .Global = False
  .IgnoreCase = False
End With
targetString = "HELLO"

response.write (re.Test(targetString))
%>

Any Ideas?
ASKER CERTIFIED SOLUTION
Avatar of aherps
aherps
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Perfect Awnser - Thanks!
A correction to disallow "" or HeLLO.

Change: ".*" and to "+" as below:
<%
Dim re, targetString
Set re = New RegExp
With re
  .Pattern = "^[A-Z]+$"
  .Global = False
  .IgnoreCase = False
End With
targetString = "HELLO"
 
response.write (re.Test(targetString))
%>

Open in new window