I do not understand this response. Using a regex such as you described is less
flexible than using split
, not more flexible: The regex will only match on lines containing at least 25 tab-separated fields. If there are fewer fields, it will fail to match and return no data. If there are more, then some fields will not be separated from each other and returned as a single field1
will work with any number of tab-separated fields right out of the box.
Going beyond split to a proper CSV-handling module, you will be able to not only read arbitrary numbers of tab-separated columns, but it will also give you the ability to recognize quoting of the fields, so that they can contain embedded tabs without causing false field separations. Accomplishing this with regexes is messy, at best.
1 ...unless you switch from (.+) to ([^\t]+), in which case it will only match lines containing exactly 25 fields.