Solved

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

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
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…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

733 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