RosettaCodeData/Task/Strip-comments-from-a-string/Mathematica/strip-comments-from-a-string.math

5 lines
201 B
Text
Raw Permalink Normal View History

2013-04-11 01:07:29 -07:00
a = "apples, pears # and bananas
apples, pears ; and bananas";
b = StringReplace[a, RegularExpression["[ ]+[#;].+[\n]"] -> "\n"];
StringReplace[b, RegularExpression["[ ]+[#;].+$"] -> ""] // FullForm