I have a EditText field in android. The password should contain minimum 4 characters and maximum 20 characters without spaces at the start or in the middle. Example blankspaceRaghu and RaghublankspaceRaghu should not be alllowed.
Pass= password.getText().toString();
Pattern p= Pattern.compile("[^\\S]+[a-z,A-Z]+");
Matcher m = p.matcher(Pass);
Updated – Spaces are allowed at the end….
This matches