PHP preg_match() must have first and last name with a space between
Posted: Tue Aug 31, 2021 4:41 pm
Hi everyone,
I am trying to create a preg_match() to allow a full name to be entered, and it must contain a space between both words. I have tried the preg_match() expressions below. They permit spaces in the name, but a space is not mandatory. Are there any hints on how to make sure there is a space between both words. Thanks.
/^[a-zA-Z ]+$/
/^[A-Z][a-zA-Z ]+$/
I am trying to create a preg_match() to allow a full name to be entered, and it must contain a space between both words. I have tried the preg_match() expressions below. They permit spaces in the name, but a space is not mandatory. Are there any hints on how to make sure there is a space between both words. Thanks.
/^[a-zA-Z ]+$/
/^[A-Z][a-zA-Z ]+$/