Java - regular expression finding comments in code

后端 未结 5 1118
感动是毒
感动是毒 2020-11-27 18:45

A little fun with Java this time. I want to write a program that reads a code from standard input (line by line, for example), like:

// some         


        
5条回答
  •  失恋的感觉
    2020-11-27 19:03

    I think a 100% correct solution using regular expressions is either inhuman or impossible (taking into account escapes, etc.).

    I believe the best option would be using ANTLR- I believe they even provide a Java grammar you can use.

提交回复
热议问题