FPAT: A Subtle Difference
As we discussed earlier,
FS describes the data between fields (“what fields are not”)
FPAT describes the fields themselves (“what fields are”).
This leads to a subtle difference in how fields are found when using regexps as the value
In order to distinguish one field from another, there must be a non-empty separator between each field. This makes intuitive sense—otherwise one could not distinguish fields from separators.
Thus, regular expression matching as done when splitting fields with
FS is not
allowed to match the null string; it must always match at least one character, in order
to be able to proceed through the entire record.
On the other hand, regular expression matching with
FPAT can match the null
string, and the non-matching intervening characters function as the separators.
This same difference is reflected in how matching is done with the
patsplit() functions (see String-Manipulation Functions).