regex - Java code for to accept 7 bit ascii characters -


this question has answer here:

i wanted code accept 7 bit ascii character set not accept 8bit characters. have tried regular expression:

user.getfirstname()).matches("[\\w\\s]+")  

there java regular expressions class set. \p{ascii}. see pattern class.

 "abc".matches("\\p{ascii}+") == true;  "abcŻ".matches("\\p{ascii}+") == false; 

Comments