How would You check if string contains exactly 2 non-adjacent spaces in PHP ?
f.e. 'John Wayne Washington' -> TRUE (2 spaces in string); 'John Wayne' -> FALSE (1 space)
Any regex pattern with explanation ?
$string = "Bush sucks big time";
$counter = count_chars($string,0);
echo $counter[32] . " spaces in the phrase.";
Use this pattern:
^[^ ]* [^ ]+ [^ ]*$
It matches a string with exactly 2 non-adjacent spaces.