diff --git a/src/Csv.php b/src/Csv.php index af727e8..094e353 100644 --- a/src/Csv.php +++ b/src/Csv.php @@ -549,9 +549,10 @@ class Csv { $this->_detect_and_remove_sep_row_from_data($data); - $pattern = sprintf('/(%1$s[^%1$s]*%1$s)/i', $this->enclosure); + $pattern = sprintf('/%1$s[^%1$s]*%1$s/i', $this->enclosure); preg_match_all($pattern, $data, $matches); + /** @var array[] $matches */ foreach ($matches[0] as $match) { if (empty($match) || (strpos($match, $this->enclosure) === false)) { continue; diff --git a/tests/methods/DataRowCountTest.php b/tests/methods/DataRowCountTest.php index 693d736..a256fde 100644 --- a/tests/methods/DataRowCountTest.php +++ b/tests/methods/DataRowCountTest.php @@ -64,7 +64,6 @@ class DataRowCountTest extends TestCase { $this->assertEquals(3, $this->csv->getTotalDataRowCount()); } - public function testGetTotalRowCountSingleEnclosure() { $this->csv->heading = false; $this->csv->enclosure = "'"; @@ -73,4 +72,11 @@ class DataRowCountTest extends TestCase { $this->assertEquals(3, $this->csv->getTotalDataRowCount()); } + public function testGetTotalRowCountSingleRow() { + $this->csv->heading = false; + $this->csv->enclosure = "'"; + $sInput = "86545235689"; + $this->csv->load_data($sInput); + $this->assertEquals(1, $this->csv->getTotalDataRowCount()); + } }