title: Regular Expression Rules in Outlook 2007?
body: <p>Is it possible to create rules in Outlook 2007 based on a regex string? </p>
  
  <p>I'm trying to add a filter for messages containing a string such as: <code>4000-10</code>, a four digit number followed by a dash and then a two digit number, which can be anything from <code>0000-00</code> to <code>9999-99</code>. </p>
  
  <p>I was using this as a regex: <code>\b[0-9]{4}\-[0-9]{2}\b</code> but the filter isn't working. I've tried a few other modifications as well with no luck. I wasn't able to find anything concrete online about whether Outlook even supports entering regexes into a rule, though, so I figured I would ask here in case I'm wasting my time.</p>
  
  <p>EDIT: Thanks to Chris's comment below, I was able to implement this filter via a macro. I thought I would share my code below in case it is able to help anyone else:</p>
  
  <pre><code>Sub JobNumberFilter(Message As Outlook.MailItem)
      Dim MatchesSubject, MatchesBody
      Dim RegEx As New RegExp
  
      'e.g. 1000-10'
      RegEx.Pattern = "([0-9]{4}-[0-9]{2})"
  
      'Check for pattern in subject and body'
      If (RegEx.Test(Message.Subject) Or RegEx.Test(Message.Body)) Then
          Set MatchesSubject = RegEx.Execute(Message.Subject)
          Set MatchesBody = RegEx.Execute(Message.Body)
          If Not (MatchesSubject Is Nothing And MatchesBody Is Nothing) Then
              'Assign "Job Number" category'
              Message.Categories = "Job Number"
              Message.Save
          End If
      End If
  End Sub
  </code></pre>