My mostly used function in transformation?

In world of data transformation / migration is the most common thing (in my case) is data verification and comparison. Usually there is source and target value and some logic in background.

Mostly used string operations by me:

  1. remove spaces
  2. remove all spaces
  3. remove special characters
  4. transform to lower case

The final:

function removeSpecialChars(str) {
 return str.replace(/(?!\w|\s)./g, '')
   .replace(/\s+/g, ' ')
   .replace(/^(\s*)([\W\w]*)(\b\s*$)/g, '$2')
   .replace(/ /g,'')
   .toLowerCase();
}