RosettaCodeData/Task/Strip-comments-from-a-string/Sidef/strip-comments-from-a-strin...

10 lines
186 B
Plaintext

func strip_comment(s) {
(s - %r'[#;].*').strip;
}
[" apples, pears # and bananas",
" apples, pears ; and bananas",
" apples, pears "].each { |s|
say strip_comment(s).dump;
};