Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 513
  • Last Modified:

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

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
ticallian
Asked:
ticallian
1 Solution
 
jml948Commented:
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
 
ozoCommented:
^[^.]*[.][^.]*$
0
 
ticallianAuthor Commented:
Thanks for the swift response, works fine!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now