Solved

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

Posted on 2008-06-16
3
488 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
Comment Utility
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
Comment Utility
^[^.]*[.][^.]*$
0
 

Author Closing Comment

by:ticallian
Comment Utility
Thanks for the swift response, works fine!
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The viewer will learn how to count occurrences of each item in an array.

763 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

7 Experts available now in Live!

Get 1:1 Help Now