Below is my rule for project name:
$this->validate(request(), [
'projectName' => 'required|regex:/(^([a-zA-z]+)(\d+)?$)/u',
];
I am trying to add the rule such that it must start with a letter from a-z
or A-z
and can end with numbers but most not.
Valid values for project name:
myproject123
myproject
MyProject
项目名称的值无效:
123myproject
!myproject
myproject 123
my project
my project123
我在网上试用了我的正则表达式:
https://regex101.com/r/FylFY1/2
它应该可以工作,但我可以通过验证,即使是project 123
.
UPDATE: It actually works, I just tested it in the wrong controller, im sorry... but maybe it will help others nevertheless