I need a regex that matches multiple things.
What im trying to do, is send a mail if the url doesnt contain certain words.
(.xml, .jpg, .ico)
My try, that didnt work:
if (!preg_match("/(\.xml)|(\.jpg)|(\.ico)/", $url))
mail("mail@mail.com", "the url doesnt contain .xml, .jpg or .ico", $url);
You’re almost there. Enclose the three extension types in one
()group separated by|and keep the.outside of it. Also, I’ve added a$to the end to indicate that the file extension occurs as the last thing in the string so something likeexample.xml.comdoesn’t accidentally match.