?
Solved

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

Posted on 2008-06-16
3
Medium Priority
?
507 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 500 total points
ID: 21794739
^[^.]*[.][^.]*$
0
 

Author Closing Comment

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

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
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.
Suggested Courses

764 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