Replace Multiple White Spaces With a Single Space

and like us on FB

The following snippet will remove double white space, tabs, and line breaks from a string.

\d, \w and \s

Shorthand character classes matching digits, word characters (letters, digits, and underscores), and whitespace (spaces, tabs, and line breaks). Can be used inside and outside character classes. \s is shorthand for [\t\n\r].