Talk:Strip comments from a string

General

Two thoughts. First, wouldn't a comment notation supporting ranges (i.e. /* ... */) as well as truncate tokens ( #, ;, // ...) be more interesting? Otherwise, I'd suggest renaming this task to Truncate a String. Second (and this is just an idle idea more than anything else), a task for which a language stripped comments (per its own language's rules; // and # for PHP, // and /* */ for C++, etc) would be very interesting, as it combines demonstrating string processing as well as the language's own comment syntax. --Michael Mol 13:53, 30 October 2010 (UTC)

Check your data

I have done this sort of thing in the past and the problem statement works if the format of what is being parsed does not allow the comment indicating character to be part of valid data.

As soon as you start to get, for example, arbitrary character strings then you need a more sophisticated parser that allows a comment marker character to appear in a string without the parser treating it as the start of a comment. --Paddy3118 04:40, 12 December 2010 (UTC)

Wayward space

What should happen to the space before the comment marker? The task description seems to silently remove it. --Paddy3118 06:15, 28 November 2010 (UTC)

I updated the description, because the original D implementation did not remove those spaces. --Rdm 12:11, 28 November 2010 (UTC)
Cheers. --Paddy3118 15:17, 28 November 2010 (UTC)

Whitespace before the comment marker should be removed. I have updated the task description to clarify this.

Cheers,

Markhobley 15:43, 28 March 2011 (UTC)

Should we treat lines without comments as if they ended with an empty comment? (In other words, should trailing white space be removed from lines without comments? Or does that not matter?) --Rdm 19:59, 29 March 2011 (UTC)
Return to "Strip comments from a string" page.