title: Generate a random string with regex
body: <p>I've an already method to generate a random string. But it's slow. I wanna improve the method using regular expression which I'm not good at.</p>
  
  <p>My code:</p>
  
  <pre><code>public string GetRandomString()
  {
     var random = new Random();
     string id = new string(Enumerable.Repeat("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789", 16)
                .Select(s =&gt; s[random.Next(s.Length)]).ToArray());
     return id;
  }
  </code></pre>
  
  <p>By using regex, I can compress the string: <code>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789</code> to some characters easily. Just like:</p>
  
  <p><code>var regex = new Regex(@"[\w\d]{16}");</code></p>
  
  <p>Is there a way to create a random string with the regex?</p>