using java, find if occurence of letter from given range if is true for the string I have a list of these strings which are formatted like the following: there are more but here are some examples
9-11 w: wwtxmsjwjwlw separate to: 9-11//int-int/range , w //char/letter , wwtxmsjwjwlw//string we are checking --false
5-6 g: wggghg separate to 5-6 , g , wgggghg --true
1-5 g: dxggdggb seperate to 1-5 , g , dxggdggb --true
5-13 f: lfgdplfffxffswck separate to 5-13 , f, lfgdplfffxffswck --true
6-7 z: zzzzgzzzz separate to 6-7 , z , zzzzgzzzz -- check if z is repeated 6-7 times in string zzzzgzzzz which here z is repeated 8 times so its not true --false
these are examples of given strings that are split into 3 different parts that share the same index in the different arrays I put them in.
The aim of the question is To take the letter/char occurrence, basically checking if the occurrence from the given range int-int is true in the string of it is true then cnt++, it's not true- nothing happens-cnt doesn't change. -but I want to check if the letter appears in the given range to the string is true- if this makes sense.
here is my attempt at coding it:
public static Scanner reader= new Scanner(System.in);
public static void main(String[] args){
int g=1000,cnt2=0;
String[] a1 = new String[g];
String[] a2 = new String[g];
String[] a3 = new String[g];
int cnt=0;
String regexp = "(?<one>\\d+-\\d+)\\s*(?<two>\\w+)\\s*:\\s*(?<three>\\w+)";
for(int i=0;i<10000;i++) {
String str = reader.nextLine();
cnt++;
Pattern pattern = Pattern.compile(regexp);
Matcher matcher = pattern.matcher(str);
if (matcher.matches()) {
a1[i]= matcher.group("one");
a2[i]= matcher.group("two");
a3[i]= matcher.group("three");
}
if(a3[i].matches("[a2[i]{a1[i]}")==true) {//("[a2[i]{a1[i]}") --a1[i] is error since its int-int and not int,int cause in regex range is {int, int} so how can i change that - to ,or change it so it works?
cnt2++;
}
}
System.out.println(cnt);
System.out.println(cnt2);
}
cnt2 is supposed to tell me how many of the inputs match the occurrence of that specific letter, doesn't work so help would be appreciated, let me know please if there are more efficient ways than my idea with the arrays. Help improving the question would also be helpful thanks