3 Replies Latest reply on Oct 28, 2006 2:41 AM by N0cT1v4Gus

    guru challenge!

    N0cT1v4Gus Level 1
      Hi guys,

      I need to make this function as fast as i can
      any idea's to make it more performant?
      If you suggest Reg. Exp. well.. i don't know how

      function MaskStr(txt,length) {
      str = Replace(txt, '<br>',chr(13) & chr(10),'ALL');
      if(len(str) gt length)
      str = left(str,length)&'...';
      return Replace(str, chr(13) & chr(10),'<br>','ALL');
      }

      Regards,

      N0cT
        • 1. Re: guru challenge!
          Dan Bracuk Level 5
          Your two replace commands appear to cancel each other out.
          • 2. Re: guru challenge!
            MikerRoo Level 1
            You can do all of that in one regex statement -- which is faster because it passes through the string only once.

            The only way to get even faster is to use pure java.

            Fastest would be assembly language.

            Finally, there is a flaw in your logic. What happens if length falls right in between chr(13) and chr(10)?
            • 3. Re: guru challenge!
              N0cT1v4Gus Level 1
              They don't "cancel each other out", because i don't know what the format of the break statement is <br> or chr13/10, if they are <br> he should cut my string like "hello world <b" so that is why i first replace it into chr13/10

              So how can i put this all in one Regular expression then ?

              Tank you !