title: Ruby RegEx/pattern-match for exact word/string matching
body: <p>Got a quick question: I have a file like this:</p>
  
  <pre><code>ip-10-0-12-84.eu-west-1.compute.internal, master, instnum=1, Running
  .....
  .....
  ip-10-0-26-118.eu-west-1.compute.internal, master_rabbit, instnum=4, Running
  ip-10-0-26-116.eu-west-1.compute.internal, master_rabbit, instnum=5, Running
  .....
  ip-10-0-26-68.eu-west-1.compute.internal, sql_master, instnum=9, Running
  ip-10-0-13-244.eu-west-1.compute.internal, nat, instnum=2, Running
  </code></pre>
  
  <p>My goal is to read the file, skipping comments (starts with <code>#</code>), empty/blank lines and the lines with <code>nat</code> or <code>master</code> in it. I tried this: </p>
  
  <pre><code>open('/tmp/runnings.txt').each do |line|
      next if line =~ /(^\s*(#|$)|nat|master)/
  </code></pre>
  
  <p>which is almost working but it also eliminates the lines with <code>master_rabbit</code> and <code>sql_master</code> in it. How can I pick only <code>master</code> and not the any other combination of that? Can it done in the same line? Cheers!!</p>