|
I wrote the following method in order to test the matching using . in my regular expression.
public void getWords(int y)
{
int x = 0;
for(y=y; y < buff.length(); y++){
String strToCompare = buff.substring(x,y); //where buff holds the partially decrypted text
x++;
Pattern p = Pattern.compile(strToCompare);
for(int z = 0; z < dict.size(); z++){
String str = (String) dict.get(z); //where dict hold all the words in the dictionary
Matcher m = p.matcher(str);
if(m.matches()){
System.out.println(str);
System.out.println(strToCompare);
}}}
// System.out.println(buff);
}
If I run the method where my parameter = 12, I am given the following output.
aestheticism
aestheti.is.
demographics
de.o.ra.....
Which suggests that the method is working correctly.
However, after running for a short time, the method cuts and gives me the error:
PatternSyntaxException:
Null(in java.util.regex.Pattern).
Does anyone know why this would occur?
|