Checking of special characteristics

Asked

Viewed 876 times

0

I need to do a check on a string on java which allows the user to insert a normal accent, but does not insert special characters such as: @#!$! etc..

I did something similar to check numerical and blank registration using 'Matches'. There is something similar to this problem?

  • I think so [^\!\"\#\$\%\&\'\(\)\*\+\,\.\/\:\;\<\=\>\?\@\\\^\_\{|}~-\0 t n r]+`

1 answer

1


I don’t know how you intend to implement, but I’ll show you two ways.

If you want to check character by character while the user is typing, you can use the Character.isLetterOrDigit(char).

Another way would be to let the user type the String complete and do the verification afterwards using the StringUtils.isAlphanumeric(String)

  • Okay, I need to create a test case that checks the list of registered strings. This test case has to check if the user has entered some special character, which will not be allowed in the system. I thought of regex, but I don’t remember what the expression was like.

  • Ok. So if you are going to check the entire String you can use Stringutils.isAlphanumeric(String)

  • Blz, I’ll do a search in this role. Thank you Eduarda!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.