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

Popular posts from this blog

c# - Move local mssql database to webhosted MYSQL -

java - How to pass parameters between Request-Scoped Controllers? -

string - what is the difference between "some" == "some\0" and strcmp("some","some\0") in c++? -