Created
June 26, 2023 04:51
-
-
Save pmatsinopoulos/f910a214d166b2469a75e0311ba0ffa5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/********************************************************************************************* | |
* 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