title: Regular expressions - C# behaves differently than Perl / Python
body: <p>Under Python:</p>
  
  <pre><code>ttsiod@elrond:~$ python
  &gt;&gt;&gt; import re
  &gt;&gt;&gt; a='This is a test'
  &gt;&gt;&gt; re.sub(r'(.*)', 'George', a)
  'George'
  </code></pre>
  
  <p>Under Perl:</p>
  
  <pre><code>ttsiod@elrond:~$ perl
  $a="This is a test";
  $a=~s/(.*)/George/;
  print $a;
  (Ctrl-D)
  
  George
  </code></pre>
  
  <p>Under C#:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Text;
  using System.Threading;
  using System.Text.RegularExpressions;
  
  namespace IsThisACsharpBug
  {
    class Program
    {
      static void Main(string[] args)
      {
          var matchPattern = "(.*)";
          var replacePattern = "George";
          var newValue = Regex.Replace("This is nice", matchPattern, replacePattern);
          Console.WriteLine(newValue);
      }
    }
  }
  </code></pre>
  
  <p>Unfortunately, C# prints:</p>
  
  <pre><code>$ csc regexp.cs
  Microsoft (R) Visual C# 2008 Compiler version 3.5.30729.5420
  for Microsoft (R) .NET Framework version 3.5
  Copyright (C) Microsoft Corporation. All rights reserved.
  
  $ ./regexp.exe 
  GeorgeGeorge
  </code></pre>
  
  <p>Is this a bug in the regular expression library of C# ? Why does it print "George" two times, when Perl and Python just print it once?</p>