remove isd code and pipe symbol from mobile number in java?

To remove isd code and pipe symbol from mobile number in java first we check mobile number is not null and empty.after that we check pipe(|) symbol is exit inside mobile number or not.now we are use subString method.this method is print mobile number after pipe symbol because we provide index number to start print.

				
					public class MobileNumberCheck {

	public static void main(String[] args) {
		String mobileNumber = "91|9888888888";
		if (null != mobileNumber && !mobileNumber.isEmpty()) {
			if (mobileNumber.contains("|")) {
				mobileNumber = mobileNumber.substring(3);
				System.out.println("mobileNo:- " + mobileNumber);
			} else {
				System.out.println("mobile Number is not available");
			}

		}
	}
}
				
			

Output :-
mobileNo:- 9888888888

Leave a Comment

Your email address will not be published. Required fields are marked *