RosettaCodeData/Task/Strip-comments-from-a-string/Mathematica/strip-comments-from-a-string.math
Ingy döt Net 68f8f3e56b all tasks
2013-04-11 01:07:29 -07:00

4 lines
201 B
Text

a = "apples, pears # and bananas
apples, pears ; and bananas";
b = StringReplace[a, RegularExpression["[ ]+[#;].+[\n]"] -> "\n"];
StringReplace[b, RegularExpression["[ ]+[#;].+$"] -> ""] // FullForm