简体   繁体   English

JSF2验证器正则表达式

[英]JSF2 validator regex

I am using following regex validator, i want validation error on whitespace if entered only and allowed chars from list az and AZ and _ and 'whitespace' and 0-9 我正在使用以下正则表达式验证器,如果只输入并允许来自列表az和AZ和_和'whitespace'和0-9的字符,我希望在空格上验证错误

Currently i have having problem with this exp it is not allowing white spaces in b/w nor in the begning. 目前,我对此exp有疑问,它不允许在黑白之间也不在黑白之间。

<f:validateRegex pattern="^\s[a-zA-Z\s_0-9]+"/>

please any quick suggestion appriciated 请提出任何快速建议

for example. 例如。

" " (When user pass empty string it should fail)
" Abc hello" (It should pass)
"Hello world" (It should pass)

尝试这个:

^[a-zA-Z\s_0-9]+\b\s*$

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM