I am trying to find lines with methods definitions in a file. For example, the line is:
// line has TAB indent
public Stream<JsonNode> requestDifferences(List<Integer> commitIds) {
The regular expression that I'm trying to use is:
"^.+(!?if|while|for|catch|do|new|return).+\\(.*\\)\\s\\{$"
The example line above matches the regular expression. But all strings that contain anonymous classes, condition, loop and return statements also successfully match the regular expression above.
What is wrong with this expression?