java - Database name Regex restriction -
java - Database name Regex restriction -
i've create java regex disable creation of databases. (i'm next these restrictions: http://dev.mysql.com/doc/refman/5.0/en/identifiers.html)
can help me build regex restriction [0-9,a-z,a-z$_] ?
this snippet:
pattern pattern = pattern.compile("[0-9a-za-z$_]"); matcher matcher = pattern.matcher("userdatabase"); system.out.println(matcher.matches());
you didn't specify quantifier. look match 1 character.
try changing to:
pattern pattern = pattern.compile("[0-9a-za-z$_]+");
the +
indicates should expressions 1 or more times.
java regex database
Comments
Post a Comment