title: Java Regular Expression to find multiple lines of a specific length
body: <p>I'm trying to use Java regexps to match a pattern that spans multiple lines.  The pattern has one line that starts with 'A' followed by exactly 50 characters and then one or more lines that start with 'B' followed by exactly 50 characters:</p>
  
  <pre><code>A...    //  exactly 50 chars after the A
  B...
  B...
  </code></pre>
  
  <p>Java Regular Expressions don't seem to support this however.  </p>
  
  <p>Here is a regexp that works for one A and one B line:</p>
  
  <pre><code>A.{50}[\\n[\\n\\r]]B.{50}[\\n[\\n\\r]]
  </code></pre>
  
  <p>Here is the same regexp modified to find one or more B lines:</p>
  
  <pre><code>A.{50}[\\n[\\n\\r]][B.{50}[\\n[\\n\\r]]]+
  </code></pre>
  
  <p>This regexp only finds the leading B character on the first B line, however.</p>
  
  <p>I use <code>[\\n[\\r\\n]]</code> to handle both DOS and UNIX newlines.  Turning on MULTILINE mode doesn't affect the results.</p>
  
  <p>The problem seems to be when I use the brackets with '+' to turn the regexp for a B line into a character class that can capture multiple lines.</p>
  
  <p>Is there something about Java regexps that don't allow the '.' character or the curly brackets to specify an exact line length?</p>