I have see numerous suggestions for regex to find whitespace in a string none of which have worked so far. Yes the concept of looping through the string with a for next loop will work. I would really like to learn how to do this with regex and Pattern Matcher ! My question is what and where do I need to add to my regex string so it will return FALSE? code below I have added numerous incarnations of (\\s) to no avail. I do not want to remove the whitespace.
I tested the code suggested as a duplicate and it does not work see the link suggested in the comments
String tstr = "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[$@$!%*?&])[A-Za-z\\d$@$!%*?&]";
String astr = etPW.getText().toString().trim();
Pattern regex = Pattern.compile(tstr);
Matcher regexMatcher = regex.matcher(astr);
boolean foundMatch = regexMatcher.find();
if(foundMatch == false){
Toast.makeText( MainActivity.this, "Password must have one Numeric Value\n"
+ "\nOne Upper & Lower Case Letters\n"
+ "\nOne Special Character $ @ ! % * ? &", Toast.LENGTH_LONG ).show();
//etPW.setText("");
//etCPW.setText("");
// Two lines of code above are optional
// Also by design these fields can be set to input type Password in the XML file
etPW.requestFocus();
return ;
}