Saturday, May 4, 2013

Regular Expression to validate file extensions

Above given solutions might not work for extensions in upper cases. Enhancing "Penguen"'s solution:

Regex regx = new Regex(@"([a-zA-Z0_9].*\bxyz)|([a-zA-Z0_9].*\bXYZ)\b");
 
Replace "xyz" with xlsx and "XYZ" with "XLSX". Please give me alternate of this expression, if it is a bulky one.

This is my answer of the question posted at stackoverflow.

No comments:

Post a Comment