onedumbcoder Posted August 3, 2009 Share Posted August 3, 2009 I cant get the right preg_match expression for a url here is what i have and it does not work: if(!empty($website)) { if(!preg_match('(https?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)', $website)) { $websiteerror .= " Invalid website."; } } Link to comment https://forums.phpfreaks.com/topic/168711-correct-preg-match-preg_match-regular-expression-for-url-in-php/ Share on other sites More sharing options...
onedumbcoder Posted August 3, 2009 Author Share Posted August 3, 2009 ttt Link to comment https://forums.phpfreaks.com/topic/168711-correct-preg-match-preg_match-regular-expression-for-url-in-php/#findComment-890124 Share on other sites More sharing options...
TeNDoLLA Posted August 3, 2009 Share Posted August 3, 2009 Maybe this thread will be helpful http://www.sitepoint.com/forums/showthread.php?t=515283&highlight=reg+exp+url . Link to comment https://forums.phpfreaks.com/topic/168711-correct-preg-match-preg_match-regular-expression-for-url-in-php/#findComment-890137 Share on other sites More sharing options...
onedumbcoder Posted August 4, 2009 Author Share Posted August 4, 2009 Can someone please help me with this. I read the links and my if statement still does not work, I have tried all of them. here what i have right now and it is not working. if(!empty($website)) { if(!preg_match('/^[a-zA-Z]+[:\/\/]+[A-Za-z0-9\-_]+\\.+[A-Za-z0-9\.\/\\+\#%&=\?\-_]+$/i', $website)) { { $websiteerror .= " Invalid website."; $erroroccured = 1; } } when i went lets say www.asdfsa.com if fails Link to comment https://forums.phpfreaks.com/topic/168711-correct-preg-match-preg_match-regular-expression-for-url-in-php/#findComment-890887 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.