Using Regular Expressions in Classic ASP

if p_value <> "" then

select case p_type
' --------------- All Numeric -----------------
Case "1" tmp_pattern = "^[0-9\\]*$"
' -------------- Alpha Numeric ----------------
Case "2" tmp_pattern = "^[a-zA-Z0-9._\-\s]{1,255}$"
' ------------- Only Alphabets ----------------
Case "3" tmp_pattern = "^[a-zA-Z]*$/"
' ------------- All Characters ----------------
Case "4" tmp_pattern = "^[a-z0-9A-Z\-\_\,\.\ \:\!\?\(\)\%\&\\]*$"
' ------------------ Email --------------------
Case "5" tmp_pattern = "^[0-9a-zA-Z\-\.\_]+@[0-9a-zA-Z\-]+\.[0-9a-zA-Z\-\.]+$"
' ------------------- URL ---------------------
Case "6" tmp_pattern = "^[a-z]+\.+[a-z]+\.+[a-z]*$"
' -------------- Phone and Fax ----------------
Case "7" tmp_pattern = "^[0-9\-\(\)\,\ \\ ]*$"
' ------------------ price --------------------
Case "8" tmp_pattern = "^[0-9\.\\ ]*$"

End Select


if trim(tmp_pattern)<>"" then
if not ExpTest(tmp_pattern, p_value) then
err_msg = "Please enter a valid value for the " & p_name & "
" end if
end if