Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 349
  • Last Modified:

Like operator to determine if alphanumeric

I am writing a condition to determine if a letter in a string is alphanumeric. It seems to be failing.

If Mid(strNew, i, 1) Like ("[A-Z]") Or Mid(strNew, i, 1) Like ("[a-z]") Or Mid(strNew, i, 1) Like ("#") Then

I keep falling into this condition even if the character is "[" or "("

This doesnt seem to be working. Is this the wrong syntax for find alpha numerics in classic ASP?
0
bertino12
Asked:
bertino12
  • 3
1 Solution
 
kevp75Commented:
i'm curious as the purpose of this....

it seems like you may want to tryout Regular Expressions for this...something like

set objRegExp = New RegExp
objRegExp.Pattern = "^([a-zA-Z0-9])"
objRegExp.Test(variable) 'for a boolean value
set objRegExp = nothing
0
 
kevp75Commented:
sorry, that should be

strTested = objRegExp.Test(variable) 'for a boolean value
0
 
jitgangulyCommented:
How about

If asc(Mid(strNew, i, 1) ) > 65 or  asc(Mid(strNew, i, 1) )< 127 Then
0
 
bertino12Author Commented:
This seems to work beautifully. thanks.

elseif objRegExp.Test(Mid(strNew, i, 1)) = true then

I am parsing through a string(from a textbox a user puts in search strings) and inserting wildcard symbols to words for an oracle query.



0
 
kevp75Commented:
ahh...

glad I could help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

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