Basic Regular Expression question

C

Chris

Trying to get started using the regular expression validator to validate
file name extensions in an file input box. I am falling at the first hurdle.
When I test for jpeg at the end of a string by using jpeg$ and then type in
'abc.jpeg' it won't accept it but when I put in 'jpeg' it will. What am I
doing wrong?
 
C

Chris

That works great but what do the .*\. sysbols mean. I can see them in my
text book but can't tie them to what you have done. Regards, Chris.
 
F

Flinky Wisty Pomm

.. means "any character"
..* means "any character repeated any number of times"
\. means "literal . character"

you might want to use instead ".+\.jpeg$" where .+ means "at least one
of any character" otherwise the string ".jpeg" is a valid match.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top