phi tran wrote:My question, would this(code below) be the best way to use regex and checking the user input?
The regex looks fine, providing you don't want to allow spaces - ie, the input must be a
single word made up entirely of letters (so nothing like "can't" or "by-product").
And I
think the loop is correct (at least it'll work); however, I suspect that if you wanted to input anything
else afterwards, you'd have to skip to a new line before you do.
The reason being that I'm pretty sure if I did something like:
enter name:
Winston The Great <Enter>
I'd get
Hello Winston. Welcome
Winston