Results 1 to 4 of 4
  1. #1
    ServletEst is offline Member
    Join Date
    Aug 2009
    Posts
    4
    Rep Power
    0

    Default validating account

    hello everyone,
    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.

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Sounds like a good job for a simple regex. Try it and post your attempts and results.

  3. #3
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    842
    Rep Power
    6

    Default

    Hi,
    Use the below regex pattern code and try out.
    Java Code:
     import java.io.*;
     import java.util.regex.*;
    
     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());
    			System.out.println(isMatch);//return true
      
    	}//main
     }//Test
    Ramya:cool:

  4. #4
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    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.

Similar Threads

  1. Using java to access internet account
    By elgem in forum Advanced Java
    Replies: 3
    Last Post: 01-18-2009, 06:49 PM
  2. Account mix problem
    By nihongbin in forum Threads and Synchronization
    Replies: 3
    Last Post: 12-10-2008, 05:05 AM
  3. Validating email address!
    By rameshraj in forum Advanced Java
    Replies: 1
    Last Post: 02-18-2008, 09:39 AM
  4. Replies: 4
    Last Post: 01-05-2008, 07:39 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •