Solved

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

Posted on 2008-06-16
3
492 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

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.
Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
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 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…

770 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