To remove isd code and pipe symbol from mobile number in java,we are perform following step :-
- First we declare a mobile number string variable with value.
- Inside if condition,checking mobile number is not null and not empty.
- From contains() method check pipe(|) symbol is exit inside mobile number or not.
- Inside subString() method,we pass index 3,this will take mobile number after pipe symbol.
- Now print the data.
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