title: String Functions how to count delimiter in string line
body: <p>I have a string line like the following :</p>
  
  <p>A:B:C:D:E:F:G:H:I:J:K:L:M</p>
  
  <p>It means delimiter ( : ) count is 12 . This line is valid.</p>
  
  <p>Now suppose you have a following line :</p>
  
  <p>A:B:C:D:E:F:G:H::::: </p>
  
  <p>This line is also valid because it contains 12 delimiter . where 8 values are present and 4 values are blank.</p>
  
  <p>Now the following line should be invalid :</p>
  
  <p>A:B:C:D:E:F: -- Invalid - because it contains only 6 values but expected are 12. </p>
  
  <p>how to do this .. ? I tried the following code , but not getting the desired output :</p>
  
  <pre><code>String strLine = "A:B:C:D:E:F:G:H:::::" ;
  int delimiterCount = 12 ; 
  
  String[] ValuesArray = strLine.split(":");
   if(ValuesArray.length != delimiterCounter){
   System.out.println(Invalid);
   }else {
   System.out.println("ValidLine");
   }
  </code></pre>
  
  <p>I am getting the output as Invalid where as it sould be Valid.</p>