Solved

VBScript Regex

Posted on 2014-04-13
3
506 Views
1 Endorsement
Last Modified: 2014-05-06
Hi,

I am looking to get a regex pattern for VBScript that can validate the following

1. A Minimum string must be at least 1 character
2. Maximum length of 15 characters.
3. Must have at lease one alphabetic character (A-Z)
4. Can also accept any of the following characters (0-9) and a hypen (-).

Thanks,

Ward.
1
Comment
Question by:whorsfall
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 35

Expert Comment

by:Dan Craciun
ID: 39997169
(?=.*[A-Z])[A-Z0-9-]{1,15}

If you want to accept small letters too, use

(?=.*[A-Za-z])[A-Za-z0-9-]{1,15}

HTH,
Dan
0
 
LVL 27

Expert Comment

by:skullnobrains
ID: 39997456
i'd assume password validation that requires at least one capital letter

(?=.*[A-Z])[A-Za-z0-9-]{1,15}
0
 
LVL 35

Accepted Solution

by:
Terry Woods earned 500 total points
ID: 39997831
Unless it's already implied by VBScript's implementation of regexes, you'll also want to put a start and end of string placeholder on your pattern:
^(?=.*[A-Z])[A-Za-z0-9-]{1,15}$

Open in new window

If you don't, the following illegal (and potentially risky) value would be valid, as the A at the end would match:
!@#$%^&*()</input>';drop table students; '%^$^&&*^*&(A

Open in new window

0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question