I"m currently studying regular expression groups. I'm having trouble fully understanding the first example presented in the book under groups. The book gives the following example:
/(\S+) (\S*) ?\b(\S+)/
I understand that this will match at most three words (consisting of any character except a white space), where the second word and space is optional.
What I have trouble understanding is the function of the boundary condition to start the match of the last group at the beginning of the third word.
When there are three words It makes no difference whether it is included or not.
When there are only two words there is a difference between group #2 and group #3
So, my question is as follows
When there are two words, why is the presence of \b
causing group#2 to be an empty string as expected, but when not present causes group #2 to contain the second word minus the last letter and group #3 to contain the last letter of the second word?