restricting char set using regex in java

-1

Basically i am trying to restrict a user not to input characters that are not allowed in username box. i found that this could be implement by String.matches()

String UcharSet = "[a-zA-Z0-9-~!@#().]+";
boolean UMORN = "Username.is@example.com".matches(UcharSet);
if(UMORN != true)
    UNotAllowedCharEC = "0x00000030";

as you can see i have string of characters to be allowed in my username box but somehow when i input @ it return false although i have it in my allowed string list.

and do tell should i add any other characters to be allowed for my username box.

java
asked on Stack Overflow Sep 2, 2016 by jacky

1 Answer

0

I just tested this and '@' results in true. You problem probably lies elsewhere.

Valid

answered on Stack Overflow Sep 2, 2016 by Kelvin • edited Jun 20, 2020 by Community

User contributions licensed under CC BY-SA 3.0