import java.io.IOException ;
import java.io.BufferedReader ;
import java.io.FileReader ;
import java.util.regex.Matcher ;
import java.util.regex.Pattern ;

public class TestCapturingGroup
{
    public static void main( String[] args ) throws IOException
    {
        BufferedReader in =
            new BufferedReader( new FileReader( "APleaForCaptainJohnBrown.txt" ) );

        StringBuffer plea = new StringBuffer() ;
        String line ;

        while ( ( line = in.readLine() ) != null )
        {
            plea.append( line );
        }

        String regex =
            "(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)" +
            "(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)" +
            "(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)" +
            "(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)" +
            "(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)" ;

        Pattern pattern = Pattern.compile( regex , Pattern.MULTILINE );
        Matcher matcher ;
        for ( int i = 0 ; i < 1000 ; i++ )
        {
            matcher = pattern.matcher( plea );

            while ( matcher.find() )
            {
                // do nothing
            }
        }
    }

    // Use of flags (such as Pattern.MULTILINE) specified when creating 
    // the pattern object is covered later in the second lesson.
}