James -
1) yes
2) yes
3) no
4) ""
So the following are words :
"ab", "ab."
The following are not words :
"ab..", "a.b", ".ab", "a.b.", "a2b."
I got it working by defining 4 separate patterns thus:
although, surely there is a better way?
Actually I think it would be a lot easier just to use the
split(" ") method on the input
String, and match each substring to
"[A-Za-z]+\.?". But I'd be interested to hear if it's possible to form a regular expression that includes the split, and why my 2nd attempt in the OP is not valid.