Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add space character to regular expression 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.

like image 684
Adnan Avatar asked Dec 03 '22 02:12

Adnan


1 Answers

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]*"/>
like image 134
alex Avatar answered Dec 24 '22 19:12

alex