RosettaCodeData/Task/Strip-block-comments/Groovy/strip-block-comments.groovy
2023-07-01 13:44:08 -04:00

20 lines
365 B
Groovy

def code = """
/**
* Some comments
* longer comments here that we can parse.
*
* Rahoo
*/
function subroutine() {
a = /* inline comment */ b + c ;
}
/*/ <-- tricky comments */
/**
* Another comment.
*/
function something() {
}
"""
println ((code =~ "(?:/\\*(?:[^*]|(?:\\*+[^*/]))*\\*+/)|(?://.*)").replaceAll(''))