diff --git a/csvkit/grep.py b/csvkit/grep.py index f9b46ab1c..ff20ddf91 100644 --- a/csvkit/grep.py +++ b/csvkit/grep.py @@ -119,5 +119,5 @@ def __init__(self, pattern): self.pattern = pattern def __call__(self, arg): - return self.pattern.match(arg) + return self.pattern.search(arg) diff --git a/tests/test_grep.py b/tests/test_grep.py index a1550f71e..bad30baed 100644 --- a/tests/test_grep.py +++ b/tests/test_grep.py @@ -122,3 +122,17 @@ def test_any_match_and_inverse(self): self.fail("Should be no more rows left.") except StopIteration: pass + + def test_multiline(self): + table = [ + ['a', 'b'], + ['1', 'foo\nbar'] + ] + fcr = FilteringCSVReader(iter(table), patterns={'b': re.compile('bar')}) + self.assertEqual(table[0], next(fcr)) + self.assertEqual(table[1], next(fcr)) + try: + next(fcr) + self.fail("Should be no more rows left.") + except StopIteration: + pass