/* Strip comments factory.
556591
function stripComments(token) {
  return strip

  /* Strip comments. */
  function strip(value) {
    var index = value.indexOf(token)

    if (index !== -1) {
      value = value.substr(0, index)
    }

    return value
  }
}
106784
function removeLineComments(content) {
  let newContent = '';
  let comment = false;
  for (let i = 0; i < content.length; i += 1) {
    const c = content[i];
    if (c === '#') {
      comment = true;
    }
    if (comment) {
      if (c === '\n') {
        comment = false;
      }
    }
    if (!comment) {
      newContent += c;
    }
  }
  return newContent;
}
831178
function getCommentLineNums(comments) {
    const lines = [];

    comments.forEach(token => {
        const start = token.loc.start.line;
        const end = token.loc.end.line;

        lines.push(start, end);
    });
    return lines;
}
67482
private function cleanAnnotations($comment)
    {
        $comment = trim(
            preg_replace(
                '#[ \t]*(?:\/\*\*|\*\/|\*)?[ \t]{0,1}(.*)?#u',
                '$1',
                $comment
            )
        );

        // reg ex above is not able to remove */ from a single line docblock
        if (substr($comment, -2) == '*/') {
            $comment = trim(substr($comment, 0, -2));
        }

        // normalize strings
        $comment = str_replace(["\r\n", "\r"], "\n", $comment);

        return $comment;
    }
352849
function (commentLine) {
    if (state === STATES.IN_COMMENT) {
        commentLine = removePrecedingAsterisks(commentLine);
        // If there is a single space after the * then remove it. Otherwise assume that the user is indenting.
        if (commentLine.indexOf("  ") !== 0 && commentLine.indexOf(" ") === 0) {
            commentLine = commentLine.substr(1);
        }
    }

    return commentLine;
}
1311855
def comment_out_magics(source):
    
    filtered = []
    for line in source.splitlines():
        if line.strip().startswith('%'):
            filtered.append('# ' +  line)
        else:
            filtered.append(line)
    return '\n'.join(filtered)
579560
public static function cleanComment($comment, $glueSeparator = ',', $uniqueValues = true)
    {
        if (!is_scalar($comment) && !is_array($comment)) {
            return '';
        }
        return trim(str_replace('*/', '*[:slash:]', is_scalar($comment) ? $comment : implode($glueSeparator, $uniqueValues ? array_unique($comment) : $comment)));
    }
36301
function collectComments(content, comments) {

    const table = []

    let from = 0
    let end

    while (true) {

        let start = content.indexOf('/*', from)

        if (start > -1) {

            end = content.indexOf('*/', start + 2)

            if (end > -1) {
                comments.push(content.slice(start + 2, end))
                table.push(content.slice(from, start))
                table.push('/*___PRESERVE_CANDIDATE_COMMENT_' + (comments.length - 1) + '___*/')
                from = end + 2

            } else {
                // unterminated comment
                end = -2
                break
            }

        } else {
            break
        }
    }

    table.push(content.slice(end + 2))

    return table.join('')
}
385309
def delete_comment(self, comment_id):
        """"""

        comment_obj = self.query(Comment).get(comment_id)
        if comment_obj:
            logger.debug("Deleting comment {0}".format(comment_obj.id))

        self.session.delete(comment_obj)
        self.save()

        return comment_obj
1233239
function removeMultiLineComments(content) {
  const beginRegExp = /(^|\n)=begin\s/;
  const endRegExp = /(^|\n)=end\s/;
  let newContent = content;
  let i = newContent.search(beginRegExp);
  let j = newContent.search(endRegExp);
  while (i !== -1 && j !== -1) {
    if (newContent[i] === '\n') {
      i += 1;
    }
    if (newContent[j] === '\n') {
      j += 1;
    }
    j += '=end'.length;
    newContent = newContent.substring(0, i) + newContent.substring(j);
    i = newContent.search(beginRegExp);
    j = newContent.search(endRegExp);
  }
  return newContent;
}
330616
public function removeComment()
    {
        $id = isset($_POST['id']) ? (int) $_POST['id'] : 0;

        if (!$comment = get_comment($id)) {
            wp_send_json_error('Comment is missing');
        }

        if (!current_user_can('edit_comment', $comment->comment_ID) && !($comment->user_id == get_current_user_id())) {
            wp_send_json_error('Missing authorization');
        }

        // Validate nonce
        if (!check_ajax_referer("delete-comment_$id", 'nonce', false)) {
            wp_send_json_error('Nonce failed');
        }

        $trashed = wp_trash_comment($comment);
        if ($trashed) {
            wp_send_json_success('Deletion was successful');
        }

        wp_send_json();
    }
888687
public function sanitizeComments($comments)
    {
        $sanitizers = $this->_comment_sanitizer;

        if (isset($sanitizers['format'])) {
            $sanitizers['format'] = $this->_repository
                                         ->getValidator()
                                         ->getFilter($sanitizers['format']);
        }

        foreach ($comments as $comment) {
            $comment->sanitizeData('body', $sanitizers);
        }
    }
389381
def _remove_single_line_import_comments(r):
    """"""
    logging.info('Removing single line import comments')
    import_r, remaining_r = split_by_last_import(r)
    new_import_r = redbaron.NodeList()
    for i, v in enumerate(import_r):
        if 1 < i < len(import_r) - 2:
            if not (
                import_r[i - 2].type != 'comment'
                and v.type == 'comment'
                and import_r[i + 2].type != 'comment'
            ) or _is_keep_comment(v):
                new_import_r.append(v)
        else:
            new_import_r.append(v)
    return new_import_r + remaining_r
320009
def filter_lines_from_comments(lines):
    
    for line_nb, raw_line in enumerate(lines):
        clean_line = remove_comments_from_line(raw_line)
        if clean_line == '':
            continue
        yield line_nb, clean_line, raw_line
788702
public static String removeComments(String s) {
        int pos = s.indexOf("#");
        if (pos == -1) {
            return s;
        }
        return s.substring(0,pos).trim();
    }
1127010
def unshift_documents(comments)
      doc_comments, other_comments = comments.partition(&:document?)
      doc_comments.reverse_each { |comment| @comments.unshift(comment) }
      other_comments
    end
185646
function emitDetachedComments(text, lineMap, writer, writeComment, node, newLine, removeComments) {
        var leadingComments;
        var currentDetachedCommentInfo;
        if (removeComments) {
            // removeComments is true, only reserve pinned comment at the top of file
            // For example:
            //      /*! Pinned Comment */
            //
            //      var x = 10;
            if (node.pos === 0) {
                leadingComments = ts.filter(ts.getLeadingCommentRanges(text, node.pos), isPinnedComment);
            }
        }
        else {
            // removeComments is false, just get detached as normal and bypass the process to filter comment
            leadingComments = ts.getLeadingCommentRanges(text, node.pos);
        }
        if (leadingComments) {
            var detachedComments = [];
            var lastComment = void 0;
            for (var _i = 0, leadingComments_1 = leadingComments; _i < leadingComments_1.length; _i++) {
                var comment = leadingComments_1[_i];
                if (lastComment) {
                    var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, lastComment.end);
                    var commentLine = getLineOfLocalPositionFromLineMap(lineMap, comment.pos);
                    if (commentLine >= lastCommentLine + 2) {
                        // There was a blank line between the last comment and this comment.  This
                        // comment is not part of the copyright comments.  Return what we have so
                        // far.
                        break;
                    }
                }
                detachedComments.push(comment);
                lastComment = comment;
            }
            if (detachedComments.length) {
                // All comments look like they could have been part of the copyright header.  Make
                // sure there is at least one blank line between it and the node.  If not, it's not
                // a copyright header.
                var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, ts.lastOrUndefined(detachedComments).end);
                var nodeLine = getLineOfLocalPositionFromLineMap(lineMap, ts.skipTrivia(text, node.pos));
                if (nodeLine >= lastCommentLine + 2) {
                    // Valid detachedComments
                    emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments);
                    emitComments(text, lineMap, writer, detachedComments, /*trailingSeparator*/ true, newLine, writeComment);
                    currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.lastOrUndefined(detachedComments).end };
                }
            }
        }
        return currentDetachedCommentInfo;
        function isPinnedComment(comment) {
            return text.charCodeAt(comment.pos + 1) === 42 /* asterisk */ &&
                text.charCodeAt(comment.pos + 2) === 33 /* exclamation */;
        }
    }