0

hello friends i am new in php,

i tried a code to remove special characters into the string, i tried the following codes,,

$user = "some string here";
preg_match_all('/[^A-Z][^a-z_-][^0-9]/', $user, $result)

but the problem is that if i give the string like : name@#$@$# it also accepted buy the preg_match but i don't want accept any special character or space in to the string just (-_) will accepted....

Please help me to solve this problem...

1
Contributor
1
Reply
2
Views
6 Years
Discussion Span
Last Post by jogesh_p
1

i found the solution guys,

i have to use

preg_match_all('/[\s|\n|\t|@|#|$|%|&|*|=]/', $user, $result )

to match special characters and also spaces into the string
the string is $user

thanks

Votes + Comments
Thanks for sharing
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.