I have a following java code:
public boolean isValidFirstName() {
return tbFName.getText().trim().matches("^(\\w+)")
& tbFName.getText().trim() != "";
}
It verifying the text with given RegEx. I want to allow the user to add a space in RegEx. I am newbie in regex.How should i do that?
Simply add space as a valid character:
Here I am using alternation (with the
|character) – so either\wor spaces are allowed.