preg_match('/^[A-Za-z]+\s[A-Za-z]+$/', $name);
would match:
FirstName MiddleName
Example: http://regex101.com/r/lE5gW4
EDIT:
Ok, this conforms more closely to what the OP is requesting.
Regex:
^([A-Z][A-Za-z]+) (?:([A-Z][A-Za-z.]+) )?([A-Z][A-Za-z]+)$
This matches the following variations..
FirstName M. LastName
FirstName LastName
FirstName MiddleName Lastname
Working regex example:
Note: and if you wanted to allow '
in the name such as in O'Brien
or any other characters, you could just add them into the character sets. ie- ([A-Z][A-Za-z.']+)
Php example:
$name = "FirstName M. LastName";
$truefalse = preg_match('/^([A-Z][A-Za-z]+) (?:([A-Z][A-Za-z.]+) )?([A-Z][A-Za-z]+)$/', $name);
echo $truefalse;
Output:
1
Working php example: