Match java core class with regex

I am writing a plugin for emacs to compile and run a java file with one click. Now I would like to know the name of the main class or if it is not. Does anyone know how to combine the name of the main java class with regexp?

My first thought in pseudo-code regex

  • find the first word preceded by "class" and it is followed by "{" ... "public static void main (String []"

Edit is how far I have come. Not fully functional, but almost ...

(?<=class ).*[^ ](?= *{.*public static void main)

I hate regex, but I like it anyway. It’s just so hard to master.

+3
source share
1 answer

Java - . , Java , .

+2

Source: https://habr.com/ru/post/1733990/


All Articles