Java Solution : regex match for alphanumeric string

If you need to check whether a password is alphanumeric or not using regex try this Java Solution : what is the difference between login.getPassword().matches(“[0-9a-zA-Z]*”); and login.getPassword().matches(“[0-9a-zA-Z]”); ? Answer : The .matches(“[0-9a-zA-Z]”) will only return true if the whole string contains just 1 digit or letter. The * in [0-9a-zA-Z]* will allow an empty string, […]

En Lire Plus

How to pad a String in Java ?

pad a String in Java : This article shows you how to use the JDK1.5 String.format() and Apache Common Lang to left or right pad a String in Java. 1. String.format : By default, the String.format() fills extra with spaces \u0020. Normally, we use replace() to pad with other chars, but it will replace the spaces in between the given string. 2. Apache Common […]

En Lire Plus