Validate a URL using regular expressions(madskristensen.dk)

submitted by madskristensenmadskristensen(8565) 5 years, 3 months ago

Today, I had to build web form that took user input from standard ASP.NET input controls. In one of the text boxes the user must to enter a valid URL, so I had to make some validation logic. But first of all, I had to find out what kind of URL’s we would accept as being valid. Based on those rules, I wrote these regular expressions

1 comment |category: |Views: 12

tags: another

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:
Comments:

posted by phaymanphayman(3550) 5 years, 3 months ago 0

Another one :
string pattern = @"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)"

Source : http://www.geekzilla.co.uk/View2D3B0109-C1B2-4B4E-BFFD-E8088CBC85FD.htm

Also, Mail and News :
string pattern = @"(?<ignore>(^|\s|\W)[\W*])?(?<uri>((mailto|news){1}:[^(//\s,)][\w\d:#@%/;$()~_?\+-=\\\.&]+))"

Source : http://www.geekzilla.co.uk/View4FE04F67-31D8-4A4C-A627-EB6EB5A3519C.htm

Reply

information Login or create an account to comment on this story