Reputation: 175
I have a multi-class java file. One of those classes contains a main method (public static void main...). Example:
class one {...}
class two {...}
class three {
public static void main(String[] args) {...}
}
I tried
class.*?[^.*?]*?main
but that matches starting at class one not class three
Upvotes: 1
Views: 288
Reputation: 166
\s*static\s*void\s*main\s*\(\s*String\s*\[\]\s*[^\)]*\)
if you want the name of class you can test this regex
class\s*([^\{]*)\{\s*.*static\s*void\s*main\s*\(\s*String\s*\[\]\s*[^\)]*\).*
Upvotes: 2