Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php regular expression. Alphabet with spaces only after the first word

Tags:

regex

php

What is a php regular expression that will allow letters and spaces. But spaces only after the first word?

Thank You

like image 727
user1384603 Avatar asked Dec 17 '22 00:12

user1384603


1 Answers

$rex = '/^[a-zA-Z][a-zA-Z ]*$/';

Or

$rex = '/^[a-z][a-z ]*$/i'; // i means case insensitive
like image 159
xdazz Avatar answered Jan 12 '23 00:01

xdazz