This might be a dumb question, but I have trouble understanding why the following code works as expected
$text = "ab cd";
$text = preg_replace("/\s+/", "", $text);
echo $text;
and outputs abcd
.
Shouldn't the backslash in \s
be escaped to get its literal meaning inside the regular expression?