Regular expression examples continued

 String challenge5 = "aaabccccccccdddefffg";
 /*  Below is used to match one or more occurences of letters from a to g */
  System.out.println(challenge5.matches("[abcdefg]+"));
  System.out.println(challenge5.matches("[a-g]+"));

  /*If we need to match the String in challenge 5 enternity we can use something like below*/
  /*We have used quantifiers below.we use carrot character ^ i.e start with 3 a's nothing before
  * the 3 a's then one b then 8 c's then 3 d's then 3 then 3 f's then 1 g then $ to make sure
  * there is nothing after the g*/

  System.out.println(challenge5.matches("^a{3}bc{8}d{3}ef{3}g$"));

 /*To verify the above works fine  we can do something like this*/

 System.out.println(challenge5.replaceAll("^a{3}bc{8}d{3}ef{3}g$","REPLACED"));

 String challenge6 = "abcd.12";
  /*Below is to check we have anything between A-z (notice the small z here) or a-z then a  . then any digits
 * and then end the String.
  //And since . means any character but we actually want to test an actual . we use escape character like this //.
  // if we only want to test 0 or 1 digits after . we can use * instead of +
   //if we want minimum of 1 digit at least we use \\d+*/
   System.out.println(challenge6.matches("^[A-z][a-z]+\\.\\d*$"));