i have found this:
$text = preg_replace('/\W+/', '-', $text);
Anyone can tell me what exactly do that? There is no information about what ‘/\W+/’ means..
Regards
Javi
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
\Wmeans a non-alphanumeric character, so anything other than a-z, A-Z, 0-9, or underscore.This is standard for regular expressions, nothing specific to Php.
Here’s a great tool for testing regular expressions:
http://www.gskinner.com/RegExr/
If you put
\W+in the box at the top you’ll see what kinds of things it matches.PS: Here’s another tool that’s simpler and cleaner, though perhaps not as feature rich:
http://rubular.com/
It includes a handy quick-reference for regular expressions at the bottom.