const xRegExp = require('xregexp');

module.exports = function(regexp, flags) {
  const lines = regexp.split('\n');
  return xRegExp(
    lines.map((line) => line.replace(/\s+#.+/, '')).join('\n'),
    flags
  );
};

const xRegExp = require('xregexp');

module.exports = (regexp, flags) => {
  const lines = regexp.split('\n');
  return xRegExp(
    lines.map((line) => line.replace(/\s+#.+/, ' ')).join('\n'),
    flags
  );
};

Use a single space in xRegExp wrapper
Use a single space in xRegExp wrapper

Removing all whitespace here is dangerous and could cause bugs if it
ends up removing spaces between a numbered backreference (e.g. \1) and a
literal number (e.g. 1). To make this safer, I am replacing it with a
single space, which will then be converted by xRegExp to `(?:)` if we
are using the `x` flag.
