在正则表达式模式[a-zA-Z] *中添加空格字符 [英] Add space character to regular expression pattern [a-zA-Z]*

查看:150
本文介绍了在正则表达式模式[a-zA-Z] *中添加空格字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用<f:validateRegex pattern="[a-zA-Z]*"/>来确保输入的值仅包含字母,它可以正常工作,但不允许在字符串中留空格.
如何在上述模式中加入空格字符? 预先感谢.

I'm using <f:validateRegex pattern="[a-zA-Z]*"/> for ensuring 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 ]*"/>

如果您需要任何空格,而不仅仅是空格,请与\s交换空格.

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

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

这篇关于在正则表达式模式[a-zA-Z] *中添加空格字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆