var outString = sourceString.replace(/[`~!@#$%^&*()_|+-=?;:'",.<>{}[]/]/gi, '');
function removeSpecialChar($string)
{
$string = strtolower($string);
$string = preg_replace('/[^da-z ]/i', '', $string);// Removes special chars.
$string = str_replace(' ', '-', $string); // Replaces all spaces with underscore.
return strtolower($string);
}
#include <iostream>
#include <string>
#include <algorithm>
int main()
{
std::string s = "#Hello #World!!";
std::string chars = "#!";
for (char c: chars) {
s.erase(std::remove(s.begin(), s.end(), c), s.end());
}
std::cout << s;
}