Jump to content

Strip comments from a string: Difference between revisions

→‎{{header|PureBasic}}: Add Python solution.
(→‎{{header|D}}: added fortran)
(→‎{{header|PureBasic}}: Add Python solution.)
Line 128:
PrintN(Strip_comments(#instring2))</pre><pre>apples, pears
apples, pears</pre>
 
=={{header|Python}}==
<lang python>>>> marker, line = '#', 'apples, pears # and bananas'
>>> line[:line.index(marker)]
'apples, pears '
>>>
>>> marker, line = ';', 'apples, pears ; and bananas'
>>> line[:line.index(marker)]
'apples, pears '</lang>
 
=={{header|REXX}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.