Hello,
I try to use a regular expression to check a name entered in a JTextArea. I would allow only the letters of the alphabet (uppercase and lowercase, with or without accents), numbers and a few more characters (space "" dashes "-" and "_" and dot "."). The problem is that I will not understand much about regular expressions. Here is my code
Code:try { if(! name.equals("")) { Matcher mt; Pattern pat = Pattern.compiles("[0-9A-Za-z_ (1)]); = pat mt.mt(name); System.out.System.out.println(mt.group()); if(mt.GroupCount() != 1) ok = false; } else ok = false; } catch(Exception e) { System.out.System.out.println(e); }
Bookmarks