I'm getting a pattern syntax exception in this regular expression:
[^c]*[c]{freq}[^c]*
It checks for the multiple occurrence of the letter C (equal to frequency or amount of times).
I'm getting a pattern syntax exception in this regular expression:
[^c]*[c]{freq}[^c]*
It checks for the multiple occurrence of the letter C (equal to frequency or amount of times).
You cannot use freq variable in regex like this. Build your regex as a String:
String regex = "[^c]*c{" + freq + "}[^c]*";
If c is also a variable then use:
String regex = "[^" + c + "]*" + c + "{" + freq + "}[^" + c + "]*";