Monday, 16 September 2013

Separation of Number And Char from String.

Separation of Number And Char from String.

Program:


public class DemoProgram {
public static void main(String[] args) {
String s = "(123)-456SS-7891ABCC";
String s1 = "(123)-456SS-7891ABCC";
   s = s.replaceAll("[^0-9]", "");
   s1 = s1.replaceAll("[^a-z|A-Z]", "");
   System.out.println("Number=="+s);
   System.out.println("Char=="+s1);

}

OutPut:
Number==1234567891
Char==SSABCC

No comments:

Post a Comment