Regex to match a C-style multiline comment

前端 未结 7 2222
忘了有多久
忘了有多久 2020-11-22 10:04

I have a string for e.g.

String src = \"How are things today /* this is comment *\\*/ and is your code  /*\\* this is another comment */ working?\"
         


        
7条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-22 10:43

    Try this which worked for me:

    System.out.println(src.replaceAll("(\/\*.*?\*\/)+",""));
    

提交回复
热议问题