I have text files to process that have been converted from pdf files. The files contain columns with data where the data is separated by multiple spaces. To make sense of the data, I use
$line=trim($line);
$line=preg_replace("/\s+/", "\t", $line);
$array=explode("\t", $line);
This works pretty well, except for 1 column which contains names. The names are separated by single spaces, some names contain 2 parts (first & last), but some names contain more than 2 parts (e.g. John F. Doe).
Is there any way that I can adjust my preg_replace
command so only multiple spaces are translated into a single tab, and single spaces are left as single spaces?