i need help in validating an account number with servlet/jsp
i really dont know how to go abt it.
the account number shuold start with anny number like 3245 and must have 22 in the middle and any number can follow and should end with 521.
Sounds like a good job for a simple regex. Try it and post your attempts and results.
Use the below regex pattern code and try out.
public class Test
//This code expects starting String should be 3245 and 22 should be in the middle and
//ends only with 521 then only it returns flag as true else false will be printed
public static void main(String args)
String regex = "3245.*.22.*.521";
String input = "324511223967521";
boolean isMatch = Pattern.matches(regex, input.trim());
The 3245 in the OP's post was an example for any number, i.e the first part should be any number. Also the middle characters should be numbers not any characters.