title: string macro replacement
body: <p>I have a Visual Studio 2008 C# .NET 3.5 application where I need to parse a macro.</p>
  
  <p>Given a serial serial number that is N digits long, and a macro like <code>%SERIALNUMBER3%</code>, I would like this parse method to return only the first 3 digits of the serial number. </p>
  
  <pre><code>string serialnumber = "123456789";
  string macro = "%SERIALNUMBER3%";
  string parsed = SomeParseMethod(serialnumber, macro);
  
  parsed = "123"
  </code></pre>
  
  <p>Given `%SERIALNUMBER7%, return the first 7 digits, etc..</p>
  
  <p>I can do this using <code>String.IndexOf</code> and some complexity, but I wondered if there was a simple method. Maybe using a <code>Regex</code> replace.</p>
  
  <p>What's the simplest method of doing this?</p>