开发者

Add space character to regular expression pattern [a-zA-Z]*

开发者 https://www.devze.com 2023-03-03 13:49 出处:网络
I\'m using <f:validateRegex pattern=\"[a-zA-Z]*\"/> for en开发者_Python百科suring that entered values contain alphabet only, it is working fine but it is not allowing to take space in the string

I'm using <f:validateRegex pattern="[a-zA-Z]*"/> for en开发者_Python百科suring that entered values contain alphabet only, it is working fine but it is not allowing to take space in the string.

How can i incorporate space character in above pattern? Thanks in advance.


Simply add the space to the regex.

<f:validateRegex pattern="[a-zA-Z ]*"/>

If you wanted any whitespace, not just space, swap the space with \s.

<f:validateRegex pattern="[a-zA-Z\\s]*"/>


This worked for me. It includes spaces in text at the start/ end of words.

/^[a-zA-Z ]+$/


I'm used this [a-zA-Z_ ]* its working for me

0

精彩评论

暂无评论...
验证码 换一张
取 消