check space present in starts and end in string javascript regex code example Example: php preg match space or start of string /\b(stackoverflow)\b/