Solved

Allow only 1 period character "." per entry using regex

Posted on 2008-06-16
3
490 Views
Last Modified: 2011-09-20
I have a page where users can upload images, i need a simple regular expression to validate that there is only one period character "." in the filename i.e. "Image.jpg" and not "Image.jpg.jpg" All other characters are allowed.

Using ASP VB
TIA
0
Comment
Question by:ticallian
3 Comments
 
LVL 2

Expert Comment

by:jml948
ID: 21794665
I don't think you need to use regex to accomplish this but could do the following:
FileStr = "Mr. John Smith"
 

Set up the array to hold the results with
 

Dim FileArray
 

then do the split, using a period as the split indicator
 

FileArray = Split(FileStr, ".")
 

if(Ubound(FileArray) > 1){

  //found more than one period code here

}else{

  //found only one period code here

}

Open in new window

0
 
LVL 84

Accepted Solution

by:
ozo earned 125 total points
ID: 21794739
^[^.]*[.][^.]*$
0
 

Author Closing Comment

by:ticallian
ID: 31467639
Thanks for the swift response, works fine!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Accessibility and Usability are two concepts that seem to be closely related.  But, too many people seem to have a distorted perception of them. During last five years, those two words have come to the day-to-day work of almost every web develope…
Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will learn how to dynamically set the form action using jQuery.

947 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

20 Experts available now in Live!

Get 1:1 Help Now