RosettaCodeData/Task/Strip-block-comments/Crystal/strip-block-comments.cr
2026-04-30 12:34:36 -04:00

22 lines
432 B
Crystal

def strip_comments (s, start_delim = "/*", end_delim = "*/")
s.gsub(/#{Regex.escape(start_delim)}.*?#{Regex.escape(end_delim)}/m, "")
end
puts strip_comments <<-EOF
/**
* Some comments
* longer comments here that we can parse.
*
* Rahoo
*/
function subroutine() {
a = /* inline comment */ b + c ;
}
/*/ <-- tricky comments */
/**
* Another comment.
*/
function something() {
}
EOF