$string =~ /^[\w-]+\.(jpg|gif)$/i;
^ means beginning of line in string
[\w-]+
[] means anything inside.. + means one or more..
\w matches.. A-Za-z0-9_..
- just means -..
\. means '.'.. because . in regexp means any one character..
(jpg|gif) means jpg or gif.. also () puts the content in the buffer.. so you could say.. $ext = $1; and you'll get the file extension of the file..
$ means end of line in string..
i means insensitive casing.. so jpg and gif can be JPG and GIF..
Jerry Su
^ means beginning of line in string
[\w-]+
[] means anything inside.. + means one or more..
\w matches.. A-Za-z0-9_..
- just means -..
\. means '.'.. because . in regexp means any one character..
(jpg|gif) means jpg or gif.. also () puts the content in the buffer.. so you could say.. $ext = $1; and you'll get the file extension of the file..
$ means end of line in string..
i means insensitive casing.. so jpg and gif can be JPG and GIF..
Jerry Su