# Very large match strings

Don Schwarz (darkowl@darkowl.pr.mcs.net)
Wed, 12 Jun 1996 18:56:54 PDT

- Messages sorted by:[ date ][ thread ][ subject ][ author ]

    On Wed, 12 Jun 1996, Nate Massey wrote:

    > What I'd like to be able to do is make a string to pass as the second
    > argument to the builtin function match() that repeats a certain sequence
    > a specified number of times.
    >
    > The whole reason for doing this (and if the guy who made $ansi_utils is
    > listening, you might be interested -- listen up! :)
    >
    That would be me.  Although it was Brack/slayer/whatever's idea to use
    regexps in my ANSI stuff, not mine.  I still haven't determined
    whether it's actually faster than using index() or strsub(), although
    it does use less ticks.  I've been wondering about your question too
    because my ANSI stuff currently uses a very long (well, not compared to
    yours) regexp that goes something like:
      %[%(white%|red%|blue%|yellow%|green%|bold%|beep%|unbold%|...%)%]
    with about 20 of those tags between the %|'s.  I'm guessing that it
    takes a lot of CPU time to parse a regexp this long but since the
    server caches them, if they're used often enough, it shouldn't matter that
    much.  But does it take a lot longer to match a string against regexp like
    that?  I'm not sure but I think so.  ANSI+ (the next version of my ANSI
    system, assuming I ever get time to work on it *sigh*) will have a more
    strict format for the ANSI tags so I will either be using index() or a
    small regexp like:
      %[%w%w:[^] ]*%]
    In addition to this, it will only run the string through this once to
    seperate the text from the ANSI so the rest of the utility verbs won't
    have to parse the string again.  Well, anyway, that probably had nothing
    to do with your question, so... While yes that should take less ticks, I
    think it will be slower than using just one
    >         %(%[%(red%|white%|blue%|bell%)%]%)*.
    in a while loop.
                                                 --Dark_Owl