Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ MUSHclient ➜ General ➜ regex speed

regex speed

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Tsunami   USA  (204 posts)  Bio
Date Wed 10 Nov 2004 01:00 PM (UTC)
Message
I was wondering about the speed of regex against the non-regex matching patterns. As I see there are 3 main cases.

1) wildcard at the begining of the match
2) wildcard in the middle
3) wildcard at the end

For each of these cases, is regex or non-regex faster. For example, doe non-regex short circuit if it finds a '*' at the end of the match?
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #1 on Wed 10 Nov 2004 07:33 PM (UTC)
Message
I imagine that MC (internally) converts non-regexps to regexps (just as clicking "convert to regexp" does).

If that were the case, Regexps would be slightly faster (because conversion isn't required).

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Nick Gammon   Australia  (23,140 posts)  Bio   Forum Administrator
Date Reply #2 on Thu 11 Nov 2004 01:24 AM (UTC)
Message
Flannel is right, they are all done internally the same way. I used to have a different matcher for the simpler (non-regexp) case, however my hand-written one turned out to be much slower. :)

He is also right, the conversion is done each time (perhaps room for improvement there?) however it should be quite fast. Basically it simply replaces each * by (.*?) and tosses ^ at the start and $ at the end. There is a bit more to it to detect things like "." inside the expression.

So, at the actual evaluation would take the same time, and you could speed things up slightly by simply clicking on "convert to regexp" for each one, although I think the saving would be slight.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


11,017 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.