I found this tool here. If you remove the backslash \ before . in provided regular expression seems to be compatible with java.util.regex.Pattern.
import java.util.regex.Pattern;
import java.util.regex.Matcher;
public class IPMatchTester {
     public static void main(String []args){
         // For 35.191.0.0/16
         Pattern p = Pattern.compile("^(35.191.(?:[0-9]|[1-9][0-9]|1(?:[0-9][0-9])|2(?:[0-4][0-9]|5[0-5])).(?:[0-9]|[1-9][0-9]|1(?:[0-9][0-9])|2(?:[0-4][0-9]|5[0-5])))$");
         int matchCount = 0;
         for( int j = 0; j <= 255; j++){
             for( int i = 0; i <= 255; i++){
                 if(!p.matcher("35.191."+ j +"." +i ).matches()){
                     System.out.println("35.191." + j + "."+ i + " no matched ");
                 } else{
                     matchCount++;
                 }
             }
         }
         System.out.println("Number of ip matched: " + matchCount);
         
         
         // For 130.211.0.0/22
         Pattern p2 = Pattern.compile("^(130.211.(?:[0-3]).(?:[0-9]|[1-9][0-9]|1(?:[0-9][0-9])|2(?:[0-4][0-9]|5[0-5])))$");
         int matchCount2 = 0;
         for( int j = 0; j <= 3; j++){
             for( int i = 0; i <=255; i++){
                 if(!p2.matcher("130.211."+ j +"." +i ).matches()){
                     System.out.println("130.211." + j + "."+ i + " no matched ");
                 } else{
                     matchCount2++;
                 }
             }
         }
         System.out.println("Number of ip matched: " + matchCount2);
     }
}