Reputation: 51
I have a referral system in my Android app with codes that look like this : ####-####-####
I know how to do for the Patterns of the email address I code you below
private boolean checkEmail() {
String email = email_tv.getText().toString();
if (!email.isEmpty() && Patterns.EMAIL_ADDRESS.matcher(email).matches()) {
checkPassword(email);
return true;
} else {
Toast.makeText(Register.this, "Vérifiez votre email", Toast.LENGTH_SHORT).show();
return false;
}
}
This Patterns.EMAIL_ADDRESS
checks if the Text corresponds to a type of email address
I would like my Pattern to look like this ####-####-####, know how to do it? If you have another method I want it!
Upvotes: 0
Views: 204
Reputation: 2740
Use this pattern : \w\w\w\w-\w\w\w\w-\w\w\w\w
and this good web page : https://regex101.com/
Upvotes: 1