title: How to search SSN from log files and XML with following characters
body: <p>I am not sure this is possible.  Possibly with a forward looking statement?  I am using a publish script conditional statement to match against Logs and SQL Server DB(XML row) for plain text SSN's.  I need to be able to match a SSN with any (possible) following characters that are not numbers using REGEX but exclude the entire match if it has more than 9 numbers with or without dashes.</p>
  
  <p>So, in my code I have something like:
      If line.text matches [REGEX PATTERN] 
      Send to report table view...</p>
  
  <p>So here are some examples:</p>
  
  <pre><code>((.*)?\d{3}(-)?\d{2}(-)?\d{4}((?!\d).*)?) 
  </code></pre>
  
  <p>^This one matches 9 or more digits.</p>
  
  <pre><code>(\d{3}(-)?\d{2}(-)?\d{4}\D*) 
  </code></pre>
  
  <p>^This one still matches on the first 9 digits</p>
  
  <pre><code>###-##-####   &lt;- 9 digits should match
  ###-##-#####  &lt;- 10 digits should not match
  #########     &lt;- should match
  ##########    &lt;- 10 digits should not match
  =#########a   &lt;- 9 digits should match
  =###-##-####a &lt;- 9 digits should match
  </code></pre>
  
  <p>I've tried a lot of variant examples but can't quite get it.  </p>
  
  <p>Any help would be appreciated...and applauded.</p>