title: Is there a way to create a string that matches a given C# regex?
body: <p>My application has a feature that parses text using a regular expression to extract special values. I find myself also needing to create strings that follow the same format. Is there a way to use the already defined regular expression to create those strings?</p>
  
  <p>For example, assume my regex looks something like this:</p>
  
  <pre><code>public static Regex MyRegex = new Regex( @"sometext_(?&lt;group1&gt;\d*)" );
  </code></pre>
  
  <p>I'd like to be able to use <code>MyRegex</code> to create a new string, something like:</p>
  
  <pre><code>var created = MyRegex.ToString( new Dictionary&lt;string, string&gt;() {{ "group1", "data1" }};
  </code></pre>
  
  <p>Such that <code>created</code> would then have the value "sometextdata1".</p>
  
  <p><strong>Update</strong>: Judging from some of the answers below, I didn't make myself clear enough. I don't want to generate random strings matching the criteria, I want to be able to create specific strings matching the criteria. In the example above, I provided "data1" to fill "group1". Basically, I have a regex that I want to use in a manner similar to format strings instead of also defining a separate format string.</p>