title: c# find and replace urls from string with regex
body: <p>i want to replace url for example www.google.com or <a href="http://www.google.com" rel="noreferrer">http://www.google.com</a> with www.google.com i have a code for this </p>
  
  <pre><code>str = Regex.Replace(str,
                  @"((http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&amp;amp;:/~\+#]*[\w\-\@?^=%&amp;amp;/~\+#])?)",
                  "&lt;a target='_blank' href='$1'&gt;$1&lt;/a&gt;");
  </code></pre>
  
  <p>it is working with <code>http://www.google.com</code> but it is not working with <code>www.google.com</code> or <code>subdomain.google.com</code> which regex code matches with every url links. and when i wrote a long link it will write same of the url for example</p>
  
  <pre><code>http://www.google.com/search/asdadad/sdsdsd/sadasdx-sadasd-weqeqwe-zxcxzc.com
  </code></pre>
  
  <p>. i want to write it as</p>
  
  <p><code>&lt;a href="http://www.google.com/search/asdadad/sdsdsd/sadasdx-sadasd-weqeqwe-zxcxzc.com"&gt;google.com/asdas... &lt;/a&gt;</code> </p>
  
  <p>what is the best way to make this? i am new for regex</p>