Hello
I need to find the right Regex to accept only user image files with the file names containing only ( 0-9, a-z, A-Z, underscores, hyphens ) of the file type .jpg , .JPG , .jpeg , .JPEG . All others must return an error...
I've tired several Regex found throughout the forums suggest by Alex, Paul, and a few others. They all seemed to fall short by accepting something than isn't valid for displaying images.
http://www.gossamer-threads.com/...orum.cgi?post=198814
http://www.gossamer-threads.com/...orum.cgi?post=158079
http://www.gossamer-threads.com/...orum.cgi?post=193435
I thought this should work but it doesn't...
^[\w^\s]+\.(jpg|JPG|jpeg|JPEG)$
From what I can see I need:
\w for (0-9, a-z, A-Z, and _ )
^/s for no whitespace
\. for the . before the file type
(jpg|JPG|jpeg|JPEG) for the file types
???? to return true for the hyphen character.
I just can't seem to get it all together to work properly!
Someone please help, I've spent to many hours trying to work this out!
I need to find the right Regex to accept only user image files with the file names containing only ( 0-9, a-z, A-Z, underscores, hyphens ) of the file type .jpg , .JPG , .jpeg , .JPEG . All others must return an error...
I've tired several Regex found throughout the forums suggest by Alex, Paul, and a few others. They all seemed to fall short by accepting something than isn't valid for displaying images.
http://www.gossamer-threads.com/...orum.cgi?post=198814
http://www.gossamer-threads.com/...orum.cgi?post=158079
http://www.gossamer-threads.com/...orum.cgi?post=193435
I thought this should work but it doesn't...
^[\w^\s]+\.(jpg|JPG|jpeg|JPEG)$
From what I can see I need:
\w for (0-9, a-z, A-Z, and _ )
^/s for no whitespace
\. for the . before the file type
(jpg|JPG|jpeg|JPEG) for the file types
???? to return true for the hyphen character.
I just can't seem to get it all together to work properly!
Someone please help, I've spent to many hours trying to work this out!