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:
A... // exactly 50 chars after the A
B...
B...
Java Regular Expressions don't seem to support this however.
Here is a regexp that works for one A and one B line:
A.{50}[\\n[\\n\\r]]B.{50}[\\n[\\n\\r]]
Here is the same regexp modified to find one or more B lines:
A.{50}[\\n[\\n\\r]][B.{50}[\\n[\\n\\r]]]+
This regexp only finds the leading B character on the first B line, however.
I use [\\n[\\r\\n]]
to handle both DOS and UNIX newlines. Turning on MULTILINE mode doesn't affect the results.
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.
Is there something about Java regexps that don't allow the '.' character or the curly brackets to specify an exact line length?