Skip to content
feuerbach edited this page Jul 17, 2011 · 5 revisions

This is a test from Regular Expression Matching Can Be Simple And Fast. A lot of regexp implementations in different languages fail this test.

Here's the evidence that regexp-applicative passes the test. Tested with v0.1.3

The test is to match the string consisting of n a's against the regexp (a?){n}a{n}.

import Text.Regex.Applicative
import Data.Traversable

rep n r = sequenceA $ replicate n r

r n = (,) <$> rep n (sym 'a' <|> pure 'b') <*> rep n (sym 'a')
*Main> replicate 30 'a' =~ r 30
Just ("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb","aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
(0.08 secs, 8400496 bytes)
Clone this wiki locally