regex - Regular expression for URL Validator -
i have issue regular expression. need validate following url
http://50.244.41.23/ http://myserver/
i have used following expressions
regex urlrx = new regex(@"(http|https)://([0-9]*)", regexoptions.ignorecase); regex urlrx = new regex(@"(http|https)://(\b(?:\d{1,3}\.){3}\d{1,3}\b)", regexoptions.ignorecase);
both working extent, doesn't serve exact purpose. gives success following strings, want expression fail such strings..
http://50.244.41.23\ http://256.244.41.23/ http://256.244.41.23.123/
can create apt regex validation above url.
thanks sebastian
here example regexes matching ipv4 addresses; "accurate" versions match valid addresses: http://answers.oreilly.com/topic/318-how-to-match-ipv4-addresses-with-regular-expressions/
by adding little more, should able match urls in form you're looking for. should match first (valid) ip address in question, not last (invalid) 3:
^https?://(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/$
Comments
Post a Comment