Skip to content

Instantly share code, notes, and snippets.

@pmatsinopoulos
Created June 26, 2023 04:51
Show Gist options
  • Save pmatsinopoulos/f910a214d166b2469a75e0311ba0ffa5 to your computer and use it in GitHub Desktop.
Save pmatsinopoulos/f910a214d166b2469a75e0311ba0ffa5 to your computer and use it in GitHub Desktop.
/*********************************************************************************************
* Returns a copy of "input" without the characters that exist inside the "setOfCharacters".
* It does the work in a case insensitive mode.
* Example: "Hello World!" with "setOfCharacters" being "oe", returns "Hll Wrld!".
*
* @param input
* @param setOfCharacters
* @returns String
*/
function squeeze(input, setOfCharacters) {
if (input === null) {
return null;
}
if (setOfCharacters === null) {
return input;
}
var re = new RegExp("[" + setOfCharacters + "]", "gi");
return input.replace(re, '');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment