Gossamer Forum
Home : Products : Gossamer Links : Pre Sales :

REXEP - the never ending quest :-)

Quote Reply
REXEP - the never ending quest :-)
Hi all,

have someone a clue how to test:

One word, something with a-z - _
then: .
then: jpg JPG gif GIF

example: some_thing-pic.GIF

Robert

Quote Reply
Re: REXEP - the never ending quest :-) In reply to
$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
Quote Reply
Re: REXEP - the never ending quest :-) In reply to
While doing a lot of things in php now i finally got the final book on this theme from Oreilly, so im glad to become an expert on regexps these days :-)
and maybe i could give something back in future. So dont hesitate to ask, if you need some things.
There is really much more in it than ask if something is a number :-)

Robert