问题
I have a problem here. My username
rule allowing to enter only letters without special characters, but could someone help me to make that it would allow letters (including special letters), but without special characters?
F.e:
Test - good, Tęęęst - good, Test2 - bad.
My rule is:
['username', 'match',
'pattern' => '/[a-z]+$/',
]
Thanks for any help
回答1:
Use this but remember it does not work on the client side since JavaScript does not support unicode regex flags (at least without special plugins):
['username', 'match', 'pattern' => '/^\p{L}+$/u']
This allows letters (in all languages) only.
来源:https://stackoverflow.com/questions/43469793/yii2-rule-which-would-allow-all-the-letters-including-special-ones-but-withou