RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
^([a-zA-Z].*|[1-9].*)\.(((j|J)(p|P)(g|G))|((g|G)(i|I)(f|F)))$
Description
Regular expression to limit types of files accepted. This example matches .jpg and .gif files only.
Matches
filename.jpg | FileName.JPG | filename.gif
Non-Matches
filename.png | filename.xxx | filename.bmp
Author Rating: Not yet rated. Ramon Hildreth
Source
Your Rating
Bad Good

Enter New Comment

Title
 
Name
 
Comment
 
Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Title: Good one
Name: Rob
Date: 11/14/2005 3:10:35 PM
Comment:
thank you sir. i can become very frustrated very quickly whenever writing regexp's. you saved me some keyboard bashing...thanks!


Title: \.([jJ][pP]([eE]?[gG]|[eE])|[gG][iI][fF]) for file extension
Name: Lou
Date: 9/8/2005 5:20:14 PM
Comment:
^([a-zA-Z].*|[1-9].*)\.([jJ][pP]([eE]?[gG]|[eE])|[gG][iI][fF])$ This change of your pattern would allow .jpg .jpeg .jpe and .gif in any mixture of upper and lower letters.


Title: There are other jpg types
Name: JJ
Date: 5/13/2005 3:45:13 PM
Comment:
Jpegs can be either jpg, jpeg, and even jpe.


Copyright © 2001-2018, RegexAdvice.com | ASP.NET Tutorials