Jak usunąć wszystkie znaki specjalne z sznurka w Javie
String str= "This#string%contains^special*characters&.";
str = str.replaceAll("[^a-zA-Z0-9]", " ");
System.out.println(str);
String str= "This#string%contains^special*characters&.";
str = str.replaceAll("[^a-zA-Z0-9]", " ");
System.out.println(str);
var outString = sourceString.replace(/[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, '');
''.join(i for i in string if i.isaplha()
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;
}