gstackoverflow gstackoverflow - 1 year ago 65
Java Question

Check that String is alphanumeric with length 1 to 5

I have wrote the following test code snippet:


However, it returns

Why and how to fix this?

Answer Source

You're escaping the first square bracket with the \\, which means the expression between the square brackets isn't treated as a character class. Remove the escaping and you should be OK:

// Here -------^
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download