My most used function in ServiceNow? Text comparison!

Servicenow - Site photo

My most used function in ServiceNow? Text comparison!

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

Mostly used string operations by me:

  1. remove spaces
  2. remove all spaces
  3. remove special characters
  4. case insensitive

The function:

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

Do you need help with data migration/integration/transformation? Let me know.