I need a Regex that will match a java method declaration. I have come up with one that will match a method declaration, but it requires the opening bracket of the method to
This is for a more specific use case but it's so much simpler I believe its worth sharing. I did this for finding 'public static void' methods i.e. Play controller actions, and I did it from the Windows/Cygwin command line, using grep; see: https://stackoverflow.com/a/7167115/34806
cat Foobar.java | grep -Pzo '(?s)public static void.*?\)\s+{'
The last two entries from my output are as follows:
public static void activeWorkEventStations (String type,
String symbol,
String section,
String day,
String priority,
@As("yyyy-MM-dd") Date scheduleDepartureDate) {
public static void getActiveScheduleChangeLogs(String type,
String symbol,
String section,
String day,
String priority,
@As("yyyy-MM-dd") Date scheduleDepartureDate) {