const spaceCase = (a) => {
  return a
    .replace(/(_|-|\.)/g, ' ')
    .replace(/([A-Z])/g, ' $1')
    .replace(/\s+/g, ' ')
    .replace(/(^\s|\s$)/g, '');
};

export default spaceCase;

const spaceCase = (a) => {
  return a
    .replace(/([A-Z])/g, ' $1')
    .replace(/(_|-|\.|\s+)/g, ' ')
    .replace(/(^\s|\s$)/g, '');
};

export default spaceCase;

Refactor spaceCase to combine "clean" & "replace" into one regex
Refactor spaceCase to combine "clean" & "replace" into one regex
