Do the needful?
Perl, 68 characters
perl -0pe's@((//).*?(\n)|(/\*).*?(\*/))@\2\4 Do the needful \3\5@sg'
This takes some liberties with the specification, and retains the original comment style. This avoids the problem with /* ... */
comments appearing before the end of the line.
No attempt is made to avoid comments within string literals, and no claim is made for the bonus points.
Perl
First world anarchy! :)
"you can never have enough needful"
#!perl -p0
sub the { s,(?<=\w)(.*)(\n),$1 // do the needful$2,g }
sub needful { s,//.*\n,\n,g,s,/\*.*?\*/,,msg }
do not do the needful
Python 3.x, regex
Since it's not code golf I didn't fuss about code length. Nothing impressive, but I had fun remembering / relearning regex basics.
import re
import urllib.request as r
def dTN(filename):
dtn = re.search(r"(?<=question-hyperlink\">)([A-Za-z \n]*)(?=[?]<)", r.urlopen("http://codegolf.stackexchange.com/questions/28625/").read().decode("utf8")).group(0)
with open(filename) as f:
return re.sub(r"//{1}.*", "//{0}".format(dtn), re.sub(r"/\*[A-Za-z \n]*\*/", "// {0}".format(dtn), f.read()))