title: Using regular expression to extract a word...if it exists
body: <p>I want to use RE to parse a log file and return the orderid if it exists. For example:</p>
  
  <p>Here is a sample log</p>
  
  <pre><code>2012-07-19 12:05:04,288 [22] INFO  AddQueueCommand [(null)] - Status set to Subscribed
  2012-07-19 12:05:04,288 [23] INFO  FooBarProviderFactory [(null)] - Missing Function : OrderId:102602 : Method:AddOrderToId : application:11
  2012-07-19 12:05:04,288 [22] INFO  AddQueueCommand [(null)] - Status set to Pending
  2012-07-19 12:05:04,288 [23] INFO  AddSubscription [(null)] - Subscription Added. OrderId:102603 : application:15
  2012-07-19 12:05:04,288 [22] INFO  AddQueueCommand [(null)] - Status set to Subscribed
  </code></pre>
  
  <p>What I want to do is use a regular expression so I can parse the components of the log message.  But when an "OrderId" exists, I want to be able to parse the orderid #.</p>
  
  <p>Here is what I have so far:</p>
  
  <pre><code>^
  (?&lt;before&gt;.*)
  (?&lt;order&gt;((?&lt;=OrderId\:\s*)\d*))
  (?&lt;after&gt;.*)
  $
  </code></pre>
  
  <p>which works great for parsing the orderids for lines that have them, but it fails when the line doesn't have them.  I tried adding the "?" zero or one to the order row which then parses all the rows, but never parses the actual orderid.  They are always null.</p>
  
  <p>Hope someone can see what I am doing wrong.  Thanks!</p>
  
  <p>(I want it to parse every line because I am going to parse multiple ids values from each row and they may or may not exist.  I want it to return the value if what I am searching for exists or null/empty if it doesn't exist.  It needs to return something for every row.  This will be plugged into LogParser so we can query or logs for specific orders or other variables)</p>