• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

guru challenge!

New Here ,
Oct 27, 2006 Oct 27, 2006

Copy link to clipboard

Copied

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
TOPICS
Advanced techniques

Views

497

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 27, 2006 Oct 27, 2006

Copy link to clipboard

Copied

Your two replace commands appear to cancel each other out.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Oct 27, 2006 Oct 27, 2006

Copy link to clipboard

Copied

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)?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 28, 2006 Oct 28, 2006

Copy link to clipboard

Copied

LATEST
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 !

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation