PHP url validation + detection

mikegoldenrod

New Member
So here is what I need to do.If an user enters this: \[code\]http://site.com\[/code\] I need to remove \[code\]http://\[/code\] so the string will be \[code\]site.com\[/code\] , if an user enters \[code\]http://www.site.com\[/code\] I need to remove \[code\]http://www.\[/code\] or if the user enters \[code\]www.site.com\[/code\] I need to remove \[code\]www.\[/code\] or he can also enter \[code\]site.com\[/code\] it will be good as well.I have a function here, but doesn't work how I want to, and I suck at regex.\[code\]preg_match('|^http(s)?://[a-z0-9-]+(.[a-z0-9-]+)*(:[0-9]+)?(/.*)?$|i', $_POST['link'])\[/code\]Can someone please help me?Best Regards
 
Back
Top