title: Fuzzy pattern matching from emails in C#
body: <p>I'm looking for a way to extract bits of data from emails. I'm primarily looking at subject lines and the email body, and extracting customer and order reference numbers. </p>
  
  <p>Imagine I'm a company where customers can email an info@mydomain.com and they might add a specific customer number or order reference in the subject line or body of the email. However, they might not always provide these references in the optimal format. I want to extract the data out, and return a probability of how likely the data is valid.</p>
  
  <p>Is there some kind of technique I can use to attempt to scan an email and return a probable customer number and or order reference with a degree of probability (a bit like Bayesian spam filtering)?</p>
  
  <p>I was considering some kind of regular expression engine, but that seemed too rigid. I was also looking at <a href="https://github.com/sethjuarez/numl" rel="nofollow">NUML.net</a> and wondering if it could help me, but I'm a little out of my depth, since I'm not entirely sure what I need. I've come across the Levenshtein algorithm, but that seems to be matching two fixed strings, rather than a fixed string and a pattern.</p>
  
  <p>I'm imagining an API that look a little like this:</p>
  
  <pre><code>// emailMessage is a Mandrill inbound object, in case anybody wonders
  EmailScanResult results = EmailScanner.Scan(emailMessage, new {ScanType.CustomerNo, ScanType.OrderReference});
  foreach (var result in results)
  {
      var scanType = result.Type; // I.e. ScanType.CustomerNo
      var score = result.Score; // e.g. 1.2
      var value = result.Value; // CU-233454345-2321
  }
  </code></pre>
  
  <p>Possible inputs for this are varied; E.g. For the same customer number:</p>
  
  <ul>
  <li>DF-232322-AB2323</li>
  <li>df-232322-AB2323</li>
  <li>232322-ab2323</li>
  <li>232322AB2323</li>
  </ul>
  
  <p>What kinds of algorithms would be useful for such a task? Are there any recommended .NET libraries for this, and do you know of any appropriate examples?</p>