title: Function To Create Regex Matching a Number Range
body: <p>I am working with the Amazon Mechanical Turk API and it will only allow me to use regular expressions to filter a field of data.</p>
  
  <p>I would like to input an integer range to a function, such as 256-311 or 45-1233, and return a regex that would match only that range.   </p>
  
  <p>A regex matching 256-321 would be:</p>
  
  <pre><code>\b((25[6-9])|(2[6-9][0-9])|(3[0-1][0-9])|(32[0-1]))\b
  </code></pre>
  
  <p>That part is fairly easy, but I am having trouble with the loop to create this regex.  </p>
  
  <p>I am trying to build a function defined like this:</p>
  
  <pre><code>function getRangeRegex( int fromInt, int toInt)
  {
  
        return regexString;
  }
  </code></pre>
  
  <p>I looked all over the web and I am surprised that it doesn't look like anyone has solved this in the past.  It is a difficult problem...</p>
  
  <p>Thanks for your time.</p>