Strip comments from a string: Difference between revisions

m
→‎{{header|Wren}}: Changed to Wren S/H
m (→‎{{header|ANSI BASIC}}: {{works with|Decimal BASIC}})
m (→‎{{header|Wren}}: Changed to Wren S/H)
 
(2 intermediate revisions by one other user not shown)
Line 779:
PrintLn(StripComments('apples, pears # and bananas'));
PrintLn(StripComments('apples, pears ; and bananas'));</syntaxhighlight>
 
=={{header|EasyLang}}==
 
<syntaxhighlight lang=easylang>
func$ strip s$ .
i = 1
repeat
c$ = substr s$ i 1
until c$ = "#" or c$ = ";" or c$ = ""
if c$ = " " and sp = 0
sp = i
elif c$ <> " "
sp = 0
.
i += 1
.
if sp = 0
sp = i
.
return substr s$ 1 (sp - 1)
.
print strip "Regular string" & "."
print strip "With a hash# a comment" & "."
print strip "With a hash # a comment" & "."
print strip "With a semicolon ; a comment" & "."
print strip "No comment " & "."
</syntaxhighlight>
 
=={{header|Erlang}}==
Line 2,256 ⟶ 2,283:
=={{header|Wren}}==
This is based on what the post 29th March, 2011 requirements appear to be.
<syntaxhighlight lang="ecmascriptwren">var markers = ["#", ";"]
 
var stripComments = Fn.new { |s|
Line 2,283 ⟶ 2,310:
' apples, pears ' -> 'apples, pears'
</pre>
 
 
=={{header|XPL0}}==
9,476

edits