matching keywords with preg_match
Posted: Wed Feb 24, 2010 4:02 pm
Hi,
I am trying to match keywords only in a string like this,
and it returns - 'A match was found' which is not I want...
how should I write the expression so that it only match keywords like 'gif' and 'jpg', in other words, i dont want it to return true if the string has 'jpge', such as above.
many thanks,
Lau
I am trying to match keywords only in a string like this,
Code: Select all
if (preg_match("(gif|jpg)", "jpge")) {
echo "A match was found.";
} else {
echo "A match was not found.";
}how should I write the expression so that it only match keywords like 'gif' and 'jpg', in other words, i dont want it to return true if the string has 'jpge', such as above.
many thanks,
Lau