title: Regex for tollfree numbers in java
body: <p>I have this regex to test for telephone # that should be a toll free.</p>
  
  <pre><code>public static final Pattern patternTollFree = Pattern.compile("^((877)|(800)|(866)|(888))");
  </code></pre>
  
  <p>So I only want to get those # where the user may have left the 1 off of the front of the string, but I have tried several things and I can't get java to match.</p>
  
  <pre><code>public String changeRingTo( String changedRinger )
  {
      if ( null == changedRinger || changedRinger.length() != 10)
          return changedRinger;
      if ( patternTollFree.matcher(changedRinger).region(0, 2).matches() )
          changedRinger = '1' + changedRinger;
      return changedRinger;
  }
  </code></pre>
  
  <p>I can't get this 2nd test case below to succeed.  What am I doing wrong?</p>
  
  <pre><code>assertEquals( "Regex not working", "8189091000", of.changeRingTo("8189091000"));
  assertEquals( "Regex not working", "18769091000", of.changeRingTo("8769091000"));
  </code></pre>