'use strict'; module.exports = function extractGarbage(body) { let snippetRegex = /(^|[^\n]+\n)([0-9a-f]+)(\s*)($|\n[^\n]+)/g; let snippets = []; let match; while (match = snippetRegex.exec(body)) { snippets.push({before: match[1], garbage: match[2], whitespace: match[3], after: match[4]}); snippetRegex.lastIndex -= match[4].length; // To allow overlapping matches } return snippets; };