Answers for "remove a special caracter from string"

0

Remove special characters

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);
		}
Posted by: Guest on December-27-2021
0

Remove special characters from string

var outString = sourceString.replace(/[`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi, '');
Posted by: Guest on May-10-2021
0

how to remove special characters from a 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;
}
Posted by: Guest on March-09-2022

Code answers related to "remove a special caracter from string"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language