Solved

VBScript Regex

Posted on 2014-04-13
3
493 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
3 Comments
 
LVL 34

Expert Comment

by:Dan Craciun
Comment Utility
(?=.*[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 26

Expert Comment

by:skullnobrains
Comment Utility
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
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
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…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now