How to remove spaces in a string? For instance:
Input:
'/var/www/site/Brand new document.docx'
Output:
'/var/www/site/Brandnewdocument.docx'
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.
This?
Example
Update: Based on this question, this:
is a better solution. It produces the same result, but it does it faster.
The Regex
\sis the regex for “whitespace”, andgis the “global” flag, meaning match ALL\s(whitespaces).A great explanation for
+can be found here.As a side note, you could replace the content between the single quotes to anything you want, so you can replace whitespace with any other string.