<commit_before>function removeWhitespace(match, value) {
  return '[' + value.replace(/ /g, '') + ']';
}

function selectorSorter(s1, s2) {
  return s1.value > s2.value ? 1 : -1;
}

var CleanUp = {
  selectors: function (selectors, removeUnsupported) {
    var plain = [];
    var tokenized = [];

    for (var i = 0, l = selectors.length; i < l; i++) {
      var selector = selectors[i];
      var reduced = selector.value
        .replace(/\s+/g, ' ')
        .replace(/ ?, ?/g, ',')
        .replace(/\s*([>\+\~])\s*/g, '$1')
        .trim();

      if (removeUnsupported && (reduced.indexOf('*+html ') != -1 || reduced.indexOf('*:first-child+html ') != -1))
        continue;

      if (reduced.indexOf('*') > -1) {
        reduced = reduced
          .replace(/\*([:#\.\[])/g, '$1')
          .replace(/^(\:first\-child)?\+html/, '*$1+html');
      }

      if (reduced.indexOf('[') > -1)
        reduced = reduced.replace(/\[([^\]]+)\]/g, removeWhitespace);

      if (plain.indexOf(reduced) == -1) {
        plain.push(reduced);
        selector.value = reduced;
        tokenized.push(selector);
      }
    }

    return {
      list: plain.sort(),
      tokenized: tokenized.sort(selectorSorter)
    };
  },

  block: function (block) {
    return block
      .replace(/(\s{2,}|\s)/g, ' ')
      .replace(/(,|:|\() /g, '$1')
      .replace(/ \)/g, ')');
  },

  atRule: function (block) {
    return block
      .replace(/\s/g, ' ')
      .replace(/\s{2,}/g, ' ')
      .trim();
  }
};
<commit_msg>Simplifies regular expressions in CleanUp module.<commit_after>function removeWhitespace(match, value) {
  return '[' + value.replace(/ /g, '') + ']';
}

function selectorSorter(s1, s2) {
  return s1.value > s2.value ? 1 : -1;
}

var CleanUp = {
  selectors: function (selectors, removeUnsupported) {
    var plain = [];
    var tokenized = [];

    for (var i = 0, l = selectors.length; i < l; i++) {
      var selector = selectors[i];
      var reduced = selector.value
        .replace(/\s+/g, ' ')
        .replace(/ ?, ?/g, ',')
        .replace(/\s*([>\+\~])\s*/g, '$1')
        .trim();

      if (removeUnsupported && (reduced.indexOf('*+html ') != -1 || reduced.indexOf('*:first-child+html ') != -1))
        continue;

      if (reduced.indexOf('*') > -1) {
        reduced = reduced
          .replace(/\*([:#\.\[])/g, '$1')
          .replace(/^(\:first\-child)?\+html/, '*$1+html');
      }

      if (reduced.indexOf('[') > -1)
        reduced = reduced.replace(/\[([^\]]+)\]/g, removeWhitespace);

      if (plain.indexOf(reduced) == -1) {
        plain.push(reduced);
        selector.value = reduced;
        tokenized.push(selector);
      }
    }

    return {
      list: plain.sort(),
      tokenized: tokenized.sort(selectorSorter)
    };
  },

  block: function (block) {
    return block
      .replace(/\s+/g, ' ')
      .replace(/(,|:|\() /g, '$1')
      .replace(/ \)/g, ')');
  },

  atRule: function (block) {
    return block
      .replace(/\s+/g, ' ')
      .trim();
  }
};

{'fraction_non_alphanumeric': 0.22959522229595222, 'fraction_numerical': 0.0112806901128069, 'mean_word_length': 2.073394495412844, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1195644', 'n_tokens_mistral': 1088, 'n_tokens_neox': 1048, 'n_words': 200}