I try to make a string pattern that can contain UTF-8 characters (öäå, etc) and match the following criteria in Java (1.7);
- Must start with # or @
- Must be lower-case
- Can contain – or _ (minus and underscore), no other special char
- Can contain digits (0-9)
- Min 3 and maximum 15 characters long
What I have at the moment that works but are missing many of the criteria.
I don’t know how to complete and add the rest of the criteria. How would a regex expression look like that can accommodate the criteria I have?
This translates into a regex in a relatively simple way:
This translates the “Min 3 and maximum 15 characters” inclusive of the
@ at the beginning. If these should not be counted, change the suffix to