Код: Выделить всё
// some comment
class Main {
/* blah */
// /* foo
foo();
// foo */
foo2();
/* // foo2 */
}
Код: Выделить всё
private static String ParseCode(String pCode)
{
String MyCommentsRegex = "(?://.*)|(/\\*(?:.|[\\n\\r])*?\\*/)";
return pCode.replaceAll(MyCommentsRegex, " ");
}
Код: Выделить всё
System.out.print("We can use /* comments */ inside a string of course, but it shouldn't start a comment");
Заранее спасибо.
Подробнее здесь: https://stackoverflow.com/questions/165 ... ts-in-code
Мобильная версия