I wrote the regex that way to have an explicit boundary between the second field and the spacing separating it from the third field. I didn't want to eat any extra spacing.
I could have accomplished this in one of three ways:
- 1) Explicitly specify that the field shouldn't contain a space at the end like I did. (.*\S)\s+
- 2) Use an explicit boundary like (.*)\b\s+
- 3) Or rely on non-greedy matching: (.*?)\s+ Which would work because of the hard boundaries for the other fields
In the end, the third method above would probably appear the cleanest, but they all accomplish the same thing in the context of the rest of the regex.