php - Symfony Validator Constraints Assert Regex -


i have entity use regex , notblank validate. need field contain english letters, without numbers. works fine, when post cyrillic don't error. why that? need english

/**  * @var string  *  * @assert\notblank()  * @assert\regex(  *           pattern= "/^\w+/",  *           match=   false,  *           message= "this text cannot contain numbers"  * )  * 

you might have problem unicode. not find if regex function unicode or ascii matching (\u option of preg_match), might make difference in case (as providing utf-8 string).

reference:

http://www.regular-expressions.info/php.html

the second problem might with:

\w+ 

which means printable characters, include letters , numbers, in encoding (if matching utf-8). in case might try:

[a-za-z]+ 

Comments