hawk / lux

Test automation framework with Expect style execution of commands
Other
136 stars 57 forks source link

Regular expression is too large error with ?+ #12

Open fredrik-hammar-dd opened 8 years ago

fredrik-hammar-dd commented 8 years ago

I was trying out the ?+ syntax but found it quickly builds too large regexes. I got Syntax error: regular expression is too large with the following:

    ?+"computeNodeAssignmentChange"
    ?+"callerRequestId":"6"
    ?+"eventTime"
    ?+"result":"ng"
    ?+"errno":"deregistrationFail"
    ?"additionalInfo":"License deregistration failed for vCPE ebuilding1aive901100, ebuilding1aive901200"

I think this could be implemented more efficiently in code than building a gigantic regex, it is very useful in some cases. In this case, I wanted to test Json output where the order of elements is implementation specific.

hawk commented 8 years ago

Have you experienced re's execution of compiled regexps to be inefficient? (An annoying upper limit is not the same as being inefficient.)

Do you have a suggestion of a more efficient algorithm?

fredrik-hammar-dd commented 8 years ago

I have really tested it before running in to the limit, but the compiled regexp was pretty riduculous it was many screens long. Since it's all permutations the length will be O(n!).

My suggestion would be to run each regexp separately each time until they all match.

You could also compile a group like (A)|(B)|(C) and check that \1 \2 \3 is not empty, but that seems like overkill to me.

I could give it a shot to implement it. I'm not sure I'll have the time, but I am curious about the internals of Lux :-)


From: H?kan Mattsson notifications@github.com Sent: Friday, August 12, 2016 10:23:37 AM To: hawk/lux Cc: Fredrik Hammar; Author Subject: Re: [hawk/lux] Regular expression is too large error with ?+ (#12)

Have you experienced re's execution of compiled regexps to be inefficient? (An annoying upper limit is not the same as being inefficient.)

Do you have a suggestion of a more efficient algorithm?

You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/hawk/lux/issues/12#issuecomment-239389281, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AHubjy3IzDp-I-PUqxdjtx1elqXjQU25ks5qfC2JgaJpZM4JiQiD.