title: RegEx.Replace is replacing more than the matched
body: <p>I'm trying to replace the following match a pattenr in xml string where the pattern is various types of attributes that are present in any given xml element.</p>
  
  <p>so if the xml string was:</p>
  
  <pre><code>&lt;TEST xlmns="https://www.test.com"&gt;
      &lt;XXX&gt;Foo&lt;/XXX&gt;
      &lt;YYY&gt;Bar&lt;/YYY&gt;
  &lt;/TEST&gt;
  </code></pre>
  
  <p>I want to remove the namespaces above using pattenr <code>.*?(?:[a-z][a-z0-9_]*).*?((?:[a-z][a-z0-9_]*))(=)(\".*?\")</code> in the below code:</p>
  
  <pre><code>namespace ConsoleApplication1
  {
      class Program
      {
          static void Main(string[] args)
          {
              var txt = "&lt;TEST xlmns=\"https://www.test.com\"&gt; &lt;XXX&gt;Foo&lt;/XXX&gt; &lt;YYY&gt;Bar&lt;/YYY&gt; &lt;/TEST&gt;";
  
              const string pattern = ".*?(?:[a-z][a-z0-9_]*).*?((?:[a-z][a-z0-9_]*))(=)(\".*?\")";    
  
              var r = new Regex(pattern, RegexOptions.IgnoreCase | RegexOptions.Singleline);
              var m = r.Match(txt);
              if (m.Success)
              {
                  String var1 = m.Groups[1].ToString();
                  String c1 = m.Groups[2].ToString();
                  String string1 = m.Groups[3].ToString();
                  Console.Write( var1.ToString() +  c1.ToString() + string1.ToString()  + "\n");
                  Console.WriteLine(RegExReplace(txt,pattern,""));
              }
              Console.ReadLine();
          }
  
          static String RegExReplace(String input, String pattern, String replacement)
          {
              if (string.IsNullOrEmpty(input))
                  return input;
  
              return Regex.Replace(input, pattern, replacement, RegexOptions.IgnoreCase);
          }
      }
  }
  </code></pre>
  
  <p>But where it matches, in this case  <code>&lt;TEST xlmns="https://www.test.com"&gt;</code> is turned into <code>&gt;</code> when it should have been <code>&lt;TEST&gt;</code></p>
  
  <p>What have i done wrong in the replace method? </p>