Regex for hyperlink and hypen problem

Posted by Maria on Stack Overflow See other posts from Stack Overflow or by Maria
Published on 2010-06-13T14:19:53Z Indexed on 2010/06/13 14:22 UTC
Read the original article Hit count: 395

Filed under:
|
|

I am trying to find links in user entered text and convert them to link automatically.

I am using current Regex as following, which good to find hyperlinks from text.

Regex regexResolveUrl = new Regex("((http://|www\\.)([A-Z0-9.-:]{1,})\\.[0-9A-Z?;~&#=\\-_\\./]{2,})", RegexOptions.Compiled | RegexOptions.IgnoreCase);

It is working good for almost all links so far i came across but it is giving problem when i want to detect links with hypen.

i.e. www.abc-xyz.com will not work, with above regex, can anyone help me with this?

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET