title: T-SQL regular expression replace
body: <p>I need to do a replacement of the string in SQL server. I know that t-sql does not completely support this regex replace feature, but we can use functions such as <code>PATINDEX</code> to do that.</p>
  
  <p>Basically, what I need is to replace a string of URL start with <strong>www</strong> or <strong>www[0-9]</strong>, for example:</p>
  
  <ul>
  <li>www.123456.com => 123456.com </li>
  <li>www2.123456.com => 123456.com</li>
  </ul>
  
  <p>I tried: <code>PATINDEX('(www[0-9]?)\.%',@url)</code>, but it does not match what I need. Does anyone know how to simply do this without a function CLR ?  </p>