I'm trying to parse text typed in a jTextArea, in the form of an algorithm in English. Initially I must recognize the main method, which is characterized by "beginning" and "end." The way I'm doing (code below), my logic only works if everything is on the same line, no matter what's between the two words for example:
start .... asdf end
I need that when typing in jTextArea, the logic works even if the line is broken by an Enter, for example:
home page
....
asdf
end
What can I do to work?
String a = jTextArea1.getText();
//----- METODO PRINCIPAL ----
boolean valInicio = a.matches("^inicio.*");
boolean valFim = a.matches(".*fim$");
if (valInicio) {
jTextArea2.setText(jTextArea2.getText() + "\nEcontrou o inicio do programa!");
if (valFim) {
jTextArea2.setText(jTextArea2.getText() + "\nEcontrou o fim do programa!");
}
}