title: Validating a Text File content using regex
body: <p>The Input text file has content as following :</p>
  
  <p>TIMINCY........ many arbitrary characters incl. white spaces and tabs</p>
  
  <p>DETAIL........ many arbitrary characters incl. white spaces and tabs</p>
  
  <p>DETAIL........ many arbitrary characters incl. white spaces and tabs</p>
  
  <p>DETAIL........ many arbitrary characters incl. white spaces and tabs</p>
  
  <p>.</p>
  
  <p>.</p>
  
  <p>. (any number of lines containing DETAILS)</p>
  
  <p>TIMINCY........ many arbitrary characters incl. white spaces and tabs</p>
  
  <p>DETAIL........ many arbitrary characters incl. white spaces and tabs</p>
  
  <p>DETAIL........ many arbitrary characters incl. white spaces and tabs</p>
  
  <p>DETAIL........ many arbitrary characters incl. white spaces and tabs</p>
  
  <p>.</p>
  
  <p>.</p>
  
  <p>.(so on)</p>
  
  <p>Q: I need to validate the file using regex so that if the file's content is NOT
  in accordance with respect to the pattern given above then I can throw CustomException.</p>
  
  <p>Please let know if you could help. Any help is appreciated cordially.</p>
  
  <pre><code>String patternString = "TMINCY"+"[.]\\{*\\}"+";"+"["+"DETAILS"+"[.]\\{*\\}"+";"+"]"+"\\{*\\}"+"]"+"\\{*\\};";
  Pattern pattern = Pattern.compile(patternString );
          String messageString = null;
  StringBuilder builder = new StringBuilder();
          try (BufferedReader reader = Files.newBufferedReader(curracFile.toPath(), charset)) {
              String line;
              while ((line = reader.readLine()) != null) {
                  builder.append(line);
                  builder.append(NEWLINE_CHAR_SEQUENCE);
              }
  
              messageString = builder.toString();
  
          } catch (IOException ex) {
              LOGGER.error(FILE_CREATION_ERROR, ex.getCause());
              throw new BusinessConversionException(FILE_CREATION_ERROR, ex);
          }   
          System.out.println("messageString is::"+messageString);
          return pattern.matcher(messageString).matches();
  </code></pre>
  
  <p>But it is Returning FALSE for correct file. Please help me with the regex.</p>