title: Matching lines by number of words with regex
body: <p>I am still new to regex and I've run into a bit of a problem. I am building a parsing script and I need to to be able to pull out lines with a certain length out of a file. </p>
  
  <p>How would I write a regex to match lines that have a certain number of words? Eg I want to match all lines in a file that have 3 words.</p>
  
  <p>Could I extend that to find all lines within certain parameters? Eg I want to match all lines in a file that have between 2 and 5 words.</p>
  
  <p>I am using perl in case that matters. Thanks!</p>