I have a text field where a user is required to input information.
JTextField data = new JTextField();
I have a requirment that if a user enters in *. Then it should be treated as a regex wildcard for when I search for the data.
I am looping through a series of files and reading each line one by one.
for(int i = 0; i < files.length; i++) {
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(files[i]));
String text = null;
while ((text = reader.readLine()) != null) {
if(text.contains(data) return text; // Line that requires wildcard check
}
} catch(IOException e) {
e.printStackTrace();
} finally{
try {
if (reader != null) {
reader.close();
}
} catch (IOException e) {}
}
}
How could I achieve this wildcard check? I require to make the '*' become any character once entered by user.