`createNewUserButton.setOnClickListener(new View.OnClickListener() {
createNewUserButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//Pattern para validar el email
Pattern pattern1 = Pattern.compile("(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%" +
"&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x" +
"7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9]" +
")?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]" +
"?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08" +
"\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])");
//Pattern para validar el nick y el contraseña
Pattern pattern2 = Pattern.compile("^.[^ ]{4,20}$");
//Recogida de email, nick y contraseña
Matcher matcherEmail = pattern1.matcher(newEmail.getText().toString());
Matcher matcherNick = pattern2.matcher(newNick.getText().toString());
Matcher matcherPassword = pattern2.matcher(newPassword.getText().toString());
//Validación
if (matcherEmail.find()
& matcherNick.find()
& matcherPassword.find()
& newPassword.getText().toString().equals(repeatNewPassword.getText().toString())){
serviceExecution("http://miip/buksu/insertUsers.php");
} else if (!matcherEmail.find()) {
Toast.makeText(getApplicationContext(), "La dirección de correo electrónico no es correcta.", Toast.LENGTH_SHORT).show();
newEmail.getText().clear();
} else if (!matcherNick.find()) {
Toast.makeText(getApplicationContext(), "El nick tiene que tener entre 5 y 20 caracteres y ningún espacio.", Toast.LENGTH_SHORT).show();
newNick.getText().clear();
} else if (!matcherPassword.find()) {
Toast.makeText(getApplicationContext(), "La contraseña tiene que tener entre 5 y 20 caracteres y ningún espacio.", Toast.LENGTH_SHORT).show();
newPassword.getText().clear();
repeatNewPassword.getText().clear();
} else {
Toast.makeText(getApplicationContext(), "Las contraseñas deben coincidir.", Toast.LENGTH_SHORT).show();
newPassword.getText().clear();
repeatNewPassword.getText().clear();
}
}
});`