Friday afternoon blag fest

Ovid publiustemp-londonpm at yahoo.com
Fri Sep 21 13:57:02 BST 2007


--- Chris Jack <chris_jack at msn.com> wrote:

> What's the longest regular expression anyone's ever written? Choose
> your own criteria for longest (e.g. #lines, #characters) although I
> suspect pitifully slow might get less respect from the audience....

I believe mine is 5214 characters, but it appears to very fast when run
against its intended target text.

Cheers,
Ovid

my $expression = (?x-ism:
    (
       
((?-xism:(?!\.(?![0-9]))(?:(?:(?i)(?:[+-]?)(?:(?=[0123456789]|[.])(?:[0123456789]*)(?:(?:[.])(?:[0123456789]{0,}))?)(?:(?:[E])(?:(?:[+-]?)(?:[0123456789]+))|))\b|\b(?-xism:[[:upper:]][[:alnum:]_]*)\b)))
        \s+
        ((?-xism:(?:(?:\\|=)?=|is|[<>]=?)))
        \s+
        ((?x-ism:
   
(?-xism:(?:(?-xism:(?:(?-xism:(?!\.(?![0-9]))(?:(?:(?i)(?:[+-]?)(?:(?=[0123456789]|[.])(?:[0123456789]*)(?:(?:[.])(?:[0123456789]{0,}))?)(?:(?:[E])(?:(?:[+-]?)(?:[0123456789]+))|))\b|\b(?-xism:[[:upper:]][[:alnum:]_]*)\b))|(?-xism:(?-xism:\()\s*(?x-ism:
   
(?-xism:(?!\.(?![0-9]))(?:(?:(?i)(?:[+-]?)(?:(?=[0123456789]|[.])(?:[0123456789]*)(?:(?:[.])(?:[0123456789]{0,}))?)(?:(?:[E])(?:(?:[+-]?)(?:[0123456789]+))|))\b|\b(?-xism:[[:upper:]][[:alnum:]_]*)\b))
    (?:
        \s*
        (?-xism:(?:\*\*|[-+*/%])) 
        \s*
       
(?-xism:(?!\.(?![0-9]))(?:(?:(?i)(?:[+-]?)(?:(?=[0123456789]|[.])(?:[0123456789]*)(?:(?:[.])(?:[0123456789]{0,}))?)(?:(?:[E])(?:(?:[+-]?)(?:[0123456789]+))|))\b|\b(?-xism:[[:upper:]][[:alnum:]_]*)\b))
    )*
)\s*(?-xism:\)))))|(?-xism:(?-xism:\()\s*(?x-ism:
   
(?-xism:(?:(?-xism:(?!\.(?![0-9]))(?:(?:(?i)(?:[+-]?)(?:(?=[0123456789]|[.])(?:[0123456789]*)(?:(?:[.])(?:[0123456789]{0,}))?)(?:(?:[E])(?:(?:[+-]?)(?:[0123456789]+))|))\b|\b(?-xism:[[:upper:]][[:alnum:]_]*)\b))|(?-xism:(?-xism:\()\s*(?x-ism:
   
(?-xism:(?!\.(?![0-9]))(?:(?:(?i)(?:[+-]?)(?:(?=[0123456789]|[.])(?:[0123456789]*)(?:(?:[.])(?:[0123456789]{0,}))?)(?:(?:[E])(?:(?:[+-]?)(?:[0123456789]+))|))\b|\b(?-xism:[[:upper:]][[:alnum:]_]*)\b))
    (?:
        \s*
        (?-xism:(?:\*\*|[-+*/%])) 
        \s*
       
(?-xism:(?!\.(?![0-9]))(?:(?:(?i)(?:[+-]?)(?:(?=[0123456789]|[.])(?:[0123456789]*)(?:(?:[.])(?:[0123456789]{0,}))?)(?:(?:[E])(?:(?:[+-]?)(?:[0123456789]+))|))\b|\b(?-xism:[[:upper:]][[:alnum:]_]*)\b))
    )*
)\s*(?-xism:\)))))
    (?:
        \s*
        (?-xism:(?:\*\*|[-+*/%])) 
        \s*
       
(?-xism:(?:(?-xism:(?!\.(?![0-9]))(?:(?:(?i)(?:[+-]?)(?:(?=[0123456789]|[.])(?:[0123456789]*)(?:(?:[.])(?:[0123456789]{0,}))?)(?:(?:[E])(?:(?:[+-]?)(?:[0123456789]+))|))\b|\b(?-xism:[[:upper:]][[:alnum:]_]*)\b))|(?-xism:(?-xism:\()\s*(?x-ism:
   
(?-xism:(?!\.(?![0-9]))(?:(?:(?i)(?:[+-]?)(?:(?=[0123456789]|[.])(?:[0123456789]*)(?:(?:[.])(?:[0123456789]{0,}))?)(?:(?:[E])(?:(?:[+-]?)(?:[0123456789]+))|))\b|\b(?-xism:[[:upper:]][[:alnum:]_]*)\b))
    (?:
        \s*
        (?-xism:(?:\*\*|[-+*/%])) 
        \s*
       
(?-xism:(?!\.(?![0-9]))(?:(?:(?i)(?:[+-]?)(?:(?=[0123456789]|[.])(?:[0123456789]*)(?:(?:[.])(?:[0123456789]{0,}))?)(?:(?:[E])(?:(?:[+-]?)(?:[0123456789]+))|))\b|\b(?-xism:[[:upper:]][[:alnum:]_]*)\b))
    )*
)\s*(?-xism:\)))))
    )*
)\s*(?-xism:\)))))
    (?:
        \s*
        (?-xism:(?:\*\*|[-+*/%]))
        \s*
       
(?-xism:(?:(?-xism:(?:(?-xism:(?!\.(?![0-9]))(?:(?:(?i)(?:[+-]?)(?:(?=[0123456789]|[.])(?:[0123456789]*)(?:(?:[.])(?:[0123456789]{0,}))?)(?:(?:[E])(?:(?:[+-]?)(?:[0123456789]+))|))\b|\b(?-xism:[[:upper:]][[:alnum:]_]*)\b))|(?-xism:(?-xism:\()\s*(?x-ism:
   
(?-xism:(?!\.(?![0-9]))(?:(?:(?i)(?:[+-]?)(?:(?=[0123456789]|[.])(?:[0123456789]*)(?:(?:[.])(?:[0123456789]{0,}))?)(?:(?:[E])(?:(?:[+-]?)(?:[0123456789]+))|))\b|\b(?-xism:[[:upper:]][[:alnum:]_]*)\b))
    (?:
        \s*
        (?-xism:(?:\*\*|[-+*/%])) 
        \s*
       
(?-xism:(?!\.(?![0-9]))(?:(?:(?i)(?:[+-]?)(?:(?=[0123456789]|[.])(?:[0123456789]*)(?:(?:[.])(?:[0123456789]{0,}))?)(?:(?:[E])(?:(?:[+-]?)(?:[0123456789]+))|))\b|\b(?-xism:[[:upper:]][[:alnum:]_]*)\b))
    )*
)\s*(?-xism:\)))))|(?-xism:(?-xism:\()\s*(?x-ism:
   
(?-xism:(?:(?-xism:(?!\.(?![0-9]))(?:(?:(?i)(?:[+-]?)(?:(?=[0123456789]|[.])(?:[0123456789]*)(?:(?:[.])(?:[0123456789]{0,}))?)(?:(?:[E])(?:(?:[+-]?)(?:[0123456789]+))|))\b|\b(?-xism:[[:upper:]][[:alnum:]_]*)\b))|(?-xism:(?-xism:\()\s*(?x-ism:
   
(?-xism:(?!\.(?![0-9]))(?:(?:(?i)(?:[+-]?)(?:(?=[0123456789]|[.])(?:[0123456789]*)(?:(?:[.])(?:[0123456789]{0,}))?)(?:(?:[E])(?:(?:[+-]?)(?:[0123456789]+))|))\b|\b(?-xism:[[:upper:]][[:alnum:]_]*)\b))
    (?:
        \s*
        (?-xism:(?:\*\*|[-+*/%])) 
        \s*
       
(?-xism:(?!\.(?![0-9]))(?:(?:(?i)(?:[+-]?)(?:(?=[0123456789]|[.])(?:[0123456789]*)(?:(?:[.])(?:[0123456789]{0,}))?)(?:(?:[E])(?:(?:[+-]?)(?:[0123456789]+))|))\b|\b(?-xism:[[:upper:]][[:alnum:]_]*)\b))
    )*
)\s*(?-xism:\)))))
    (?:
        \s*
        (?-xism:(?:\*\*|[-+*/%])) 
        \s*
       
(?-xism:(?:(?-xism:(?!\.(?![0-9]))(?:(?:(?i)(?:[+-]?)(?:(?=[0123456789]|[.])(?:[0123456789]*)(?:(?:[.])(?:[0123456789]{0,}))?)(?:(?:[E])(?:(?:[+-]?)(?:[0123456789]+))|))\b|\b(?-xism:[[:upper:]][[:alnum:]_]*)\b))|(?-xism:(?-xism:\()\s*(?x-ism:
   
(?-xism:(?!\.(?![0-9]))(?:(?:(?i)(?:[+-]?)(?:(?=[0123456789]|[.])(?:[0123456789]*)(?:(?:[.])(?:[0123456789]{0,}))?)(?:(?:[E])(?:(?:[+-]?)(?:[0123456789]+))|))\b|\b(?-xism:[[:upper:]][[:alnum:]_]*)\b))
    (?:
        \s*
        (?-xism:(?:\*\*|[-+*/%])) 
        \s*
       
(?-xism:(?!\.(?![0-9]))(?:(?:(?i)(?:[+-]?)(?:(?=[0123456789]|[.])(?:[0123456789]*)(?:(?:[.])(?:[0123456789]{0,}))?)(?:(?:[E])(?:(?:[+-]?)(?:[0123456789]+))|))\b|\b(?-xism:[[:upper:]][[:alnum:]_]*)\b))
    )*
)\s*(?-xism:\)))))
    )*
)\s*(?-xism:\)))))
    )*
))
    )
    (?=[,.])
)x;


More information about the london.pm mailing list