gijew Posted June 13, 2007 Share Posted June 13, 2007 I'm hoping someone can help me out with this regular expression. I've been modifying this for about an hour and have only managed to validate the first part (being the http://localhost). I'm not super with regex so I could really use a hand and getting this to validate here.. What I'm attempting at doing is validate the following. http://localhost/ [PASS] http://localhost/page.html [PASS] http://localhost/page.php?A=1 [PASS] http://www.site.com [FAIL] ^((ht|f)tp://)((([a-z0-9-]+(\.))|(([0-9]{1,3}\.){3}([0-9]{1,3})))((/|\?)[a-zA-Z0-9~#%&'_\+=:\?\.-]*)*)$ Yes, I am trying to validate URLS so either a localhost or IP address will pass. There is also the page | directory / extension + any queries. I would really appreciate your kind help here. Thank you! Quote Link to comment Share on other sites More sharing options...
gijew Posted June 13, 2007 Author Share Posted June 13, 2007 Got it to work. FYI: For those that are curious about getting this to work. ^(ht|f)tp://([0-9][.][0-9][.][0-9][.][0-9]|localhost)(/.*|)$ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.