title: Finding lines in a text file matching a regular expression
body: <p>Can anyone explain how I could use regular expressions in Ruby to only return the matches of a string. </p>
  
  <p>For example, if the code reads in a .txt file with a series of names in it:</p>
  
  <pre class="lang-none prettyprint-override"><code>John Smith
  James Jones
  David Brown
  Tom Davidson
  etc etc
  </code></pre>
  
  <p>..and the word to match is typed in as being 'ohn', it would then just return 'John Smith', but none of the other names.</p>