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
Solved

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

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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
The viewer will learn how to count occurrences of each item in an array.
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…

792 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