7 December 2017 Snippet - Preg Match To check string with no whitespace usually used for to check for username preg_match('/^[A-Za-z0-9-_",'s][w]+$/', $string)