Hello World Hello Worldhello world Hello WorldIt works if $q has normal values but I am getting $q value from search input and so it does not work except case 1.
$q = Input::get('q');
if(preg_match("/^\s+/", $q) || preg_match("/\s{2,}/", $q)) {
echo 'Found Spaces';
}
Instead of Input::get('q'); use $q = $_GET['q'];
So your code becomes:
$q = $_GET['q'];
if(preg_match("/^\s+/", $q) || preg_match("/\s{2,}/", $q)) {
echo 'Found Spaces';
}
if(preg_match("/^\s+/", $q) || preg_match("/\s{2,}/", $q))
{
}
/\s+/g
\s to match space.+ to said at least one.g globally tag, all matches.