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

14 lines
416 B
Plaintext

strip = function(test)
comment = test.indexOf("#")
if comment == null then comment = test.indexOf(";")
if comment then test = test[:comment]
while test[-1] == " "
test = test - " "
end while
return test
end function
print strip("This is a hash test # a comment") + "."
print strip("This is a semicolon test ; a comment") + "."
print strip("This is a no comment test ") + "."