I have a question \"The name must be of non-zero length and consist of only lett
ID: 3637597 • Letter: I
Question
I have a question "The name must be of non-zero length and consist of only letters and at most one blank, which cannot be the first or last character."Can't figure out the Regex, I think this statement is correct
This is for an API, so it would be
Regex = [something here]
public void setName(String name) throws IllegalArgumentException
{
String newname = name.split(Regex);
if (!name.isEmpty() && newname)
{
this.name = name;
}
else
{
throw new IllegalArgumentException();
}
return;
{
Thanks.
Explanation / Answer
Regex = [A-Za-zs{2,}]
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.