• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 974
  • Last Modified:

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?
0
TheAnvilGroup
Asked:
TheAnvilGroup
  • 3
  • 2
1 Solution
 
aherpsCommented:
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
0
 
TheAnvilGroupAuthor Commented:
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?
0
 
aherpsCommented:
Sorry - should read as follows. Had put rs in place of an re.


<%
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

0
 
TheAnvilGroupAuthor Commented:
Perfect Awnser - Thanks!
0
 
aherpsCommented:
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

0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now