Reputation: 383
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).
Upvotes: 0
Views: 62
Reputation: 785246
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 + "]*";
Upvotes: 1