title: How can I find code with a specific string, but not in comments
body: <p>I'm trying to search through 1,000's of stored procedures and functions for a particular string (in this case an email address), but I want to ignore it when it's in a comment block.</p>
  
  <p>This is the SQL syntax to find the objects, but there are hundreds of results and I don't want to go through each one to determine if the email address is being utilized in code or just in a comment block.</p>
  
  <pre><code>SELECT DISTINCT
    o.name objectname
  FROM sys.sql_modules m
    INNER JOIN sys.objects o 
      ON m.object_id = o.object_id
  WHERE definition LIKE '%somebody@somewhere.com%'
  ORDER BY o.name
  </code></pre>
  
  <p>I have a CLR library (SQLSharp) where I can use regex, but I'm not sure of the regex expression that would identify a comment vs valid code.</p>
  
  <p>For those who are RegEx savvy and not SQL Server savvy, a comment is defined as a single line starting with two dashes (e.g. --) or multiple lines starting with /* and ending with */</p>
  
  <p>Just the thought of trying to figure this out makes my brain hurt.</p>