vbsouthern Posted May 1, 2009 Share Posted May 1, 2009 This code works if the user only enters 1 domain name. If the user enters many domain names then it stops working. $pattern = '/[.]+(biz|com|edu|gov|info|net|org|tw|uk|us)$/ix';if (preg_match($pattern, "$message")) { $validate = "Error"; $usermssg = "Domain names are not allowed in message.";} Can anyone tell my why this does not work for multiple entries and what should I change to make it work for both? Link to comment Share on other sites More sharing options...
Synook Posted May 1, 2009 Share Posted May 1, 2009 Because the $ sign at the end of the regex means "the end of the string must be here" - i.e. it won't match if there is anything after it. Link to comment Share on other sites More sharing options...
justsomeguy Posted May 1, 2009 Share Posted May 1, 2009 Just to point out, that regex isn't going to match a domain name, it's going to match any set of characters that ends in "biz", "com", "edu", "info", etc. That will match the string "I'm looking for info", which obviously isn't a domain name. It will not match the string "http://goatse.cx/", however, which it probably should. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.