struct StringsBase *StringsBase=0L; /*#define RUN*/ #ifdef RUN char *RepStrBetweenWithStrs(s,as,bs,rs) register char *s,*as,*bs,*rs; { register char *p,*ap,*bp,*cp,*rp,*pp,c; register long l,el; l=(long)s; p=s; if(s) if(!*as) p=0; if(p) { l=StrLen(rs); p=s; do { ap=(char *)StrStr(p,as); rp=rs; if(ap) { p=ap; bp=as; do p++; while(*bp++); /* Go EOS */ p--; bp=(char *)AfterStrStr(p,bs); el=bp-ap; if(l<=el) { c=*bp; p=ap+l; if(l) { do; while(*ap++=*rp++); } if(l) ap--; *ap=c; do; while(*ap++=*bp++); } if(l>el) { cp=bp; do ; while(*cp++); /* Go EOS */ c=*bp; el=bp-ap; pp=cp; p=ap; cp+=l-el; /* New EOS */ do *cp--=*pp--; while(bp(bp-ap)) {*/ } /* if(ap) */ } while(ap); } /*if(s) { */ return s; /* $VER: 0.1 */ }; #endif long test(s,as,bs,rs,outs) char *s; char *as; char *bs; char *rs; char *outs; { long el=0,l; char os[256],*p; StrCpy(os,s); printf("\nInput = <%s> LEN = %ld\n",s,StrLen(s)); if(as) printf("IN as <%s> %ld ",as,(long)strlen(as)); if(bs) printf("bs <%s> %ld ",bs,(long)StrLen(bs)); printf("Replace = <%s> LEN = %ld\n",rs,StrLen(rs)); p=(char *)RepStrBetweenWithStrs(os,as,bs,rs); printf("return = <%s> %x LEN = %ld\n",p,p,l=(long)StrLen(p)); if(!p) printf("NOT FOUND "); if(!as) printf("as = NULL "); if(!bs) printf("bs = NULL "); printf("OUTPUT = <%s> %x LEN = %ld\n",os,os,l); sprintf(os,"%2ld ",l); StrCat(outs,os); StrCat(outs," "); return el; /* */ } int main() { /* MAIN */ long el=0; char *p,s[1024],as[1024],rs[256],o[256]; el--; strcpy(rs,"test"); StringsBase=(struct StringsBase *)OpenLibrary("Strings.library",0); StrCpy(s,"138,350,00
"); StrCpy(o,""); el=test(s,">","<","******",o); StrCpy(as,"html codeDEM"); StrCpy(s,"html codeDEM142,50138,350,00
"); el=test(s,"<",">","",o); el=test(s,"<",">"," ",o); el=test(s,">","<","******",o); el=test(s,"<",">","******",o); el=test(s,"<",">","",o); el=test(s,">","<","",o); el=test(s,"","","++++",o); el=test(s,"html","","++++",o); el=test(s,"html",""," ",o); el=test(s,"html",""," ",o); el=test(s,"html",""," ",o); el=test(s,"html",""," ",o); el=test(s,"TD","","",o); el=test(s,"TD","","HTML",o); el=test(s,"T","","+++",o); el=test(s,"<",">",0,o); el=test(s,"","","",o); el=test(s,"","","@",o); el=test(s,"","","test",o); printf("%s \n",o); if(StringsBase) CloseLibrary(StringsBase); return el; } /* END */ #ifdef COMMENT Input = <138,350,00
> LEN = 38 IN as <>> 1 bs <<> 1 Replace = <******> LEN = 6 return = < 286364 LEN = 53 OUTPUT = < 286364 LEN = 53 Input = <html codeDEM142,50138,350,00
> LEN = 84 IN as <<> 1 bs <>> 1 Replace = <> LEN = 0 return = 286364 LEN = 28 OUTPUT = 286364 LEN = 28 Input = <html codeDEM142,50138,350,00
> LEN = 84 IN as <<> 1 bs <>> 1 Replace = < > LEN = 1 return = < html code DEM 142,50 138,35 0,00 > 286364 LEN = 41 OUTPUT = < html code DEM 142,50 138,35 0,00 > 286364 LEN = 41 Input = <html codeDEM142,50138,350,00
> LEN = 84 IN as <>> 1 bs <<> 1 Replace = <******> LEN = 6 return = < 286364 LEN = 109 OUTPUT = < 286364 LEN = 109 Input = <html codeDEM142,50138,350,00
> LEN = 84 IN as <<> 1 bs <>> 1 Replace = <******> LEN = 6 return = <************html code************DEM************142,50************138,35************0,00******************> 286364 LEN = 106 OUTPUT = <************html code************DEM************142,50************138,35************0,00******************> 286364 LEN = 106 Input = <html codeDEM142,50138,350,00
> LEN = 84 IN as <<> 1 bs <>> 1 Replace = <> LEN = 0 return = 286364 LEN = 28 OUTPUT = 286364 LEN = 28 Input = <html codeDEM142,50138,350,00
> LEN = 84 IN as <>> 1 bs <<> 1 Replace = <> LEN = 0 return = < 286364 LEN = 31 OUTPUT = < 286364 LEN = 31 Input = <html codeDEM142,50138,350,00
> LEN = 84 IN as <> 0 bs <> 0 Replace = <++++> LEN = 4 return = <html codeDEM142,50138,350,00
> 286364 LEN = 84 OUTPUT = <html codeDEM142,50138,350,00
> 286364 LEN = 84 Input = <html codeDEM142,50138,350,00
> LEN = 84 IN as 4 bs <> 0 Replace = <++++> LEN = 4 return = <++++ codeDEM142,50138,350,00
> 286364 LEN = 84 OUTPUT = <++++ codeDEM142,50138,350,00
> 286364 LEN = 84 Input = <html codeDEM142,50138,350,00
> LEN = 84 IN as 4 bs <> 0 Replace = < > LEN = 1 return = < codeDEM142,50138,350,00
> 286364 LEN = 81 OUTPUT = < codeDEM142,50138,350,00
> 286364 LEN = 81 Input = <html codeDEM142,50138,350,00
> LEN = 84 IN as 4 bs <> 0 Replace = < > LEN = 2 return = < codeDEM142,50138,350,00
> 286364 LEN = 82 OUTPUT = < codeDEM142,50138,350,00
> 286364 LEN = 82 Input = <html codeDEM142,50138,350,00
> LEN = 84 IN as 4 bs <> 0 Replace = < > LEN = 3 return = < codeDEM142,50138,350,00
> 286364 LEN = 83 OUTPUT = < codeDEM142,50138,350,00
> 286364 LEN = 83 Input = <html codeDEM142,50138,350,00
> LEN = 84 IN as 4 bs <> 0 Replace = < > LEN = 4 return = < codeDEM142,50138,350,00
> 286364 LEN = 84 OUTPUT = < codeDEM142,50138,350,00
> 286364 LEN = 84 Input = <html codeDEM142,50138,350,00
> LEN = 84 IN as 2 bs <> 0 Replace = <> LEN = 0 return = <html codeDEM<>142,50< >138,35<>0,00
> 286364 LEN = 70 OUTPUT = <html codeDEM<>142,50< >138,35<>0,00
> 286364 LEN = 70 Input = <html codeDEM142,50138,350,00
> LEN = 84 IN as 2 bs <> 0 Replace = LEN = 4 return = <html codeDEM142,50138,350,00
> 286364 LEN = 98 OUTPUT = <html codeDEM142,50138,350,00
> 286364 LEN = 98 Input = <html codeDEM142,50138,350,00
> LEN = 84 IN as 1 bs <> 0 Replace = <+++> LEN = 3 return = <<+++R><+++>html code<+++>DEM<+++D>142,50<+++D >138,35<+++D>0,00
> 286364 LEN = 108 OUTPUT = <<+++R><+++>html code<+++>DEM<+++D>142,50<+++D >138,35<+++D>0,00
> 286364 LEN = 108 Input = <html codeDEM142,50138,350,00
> LEN = 84 IN as <<> 1 bs <>> 1 Replace = <> LEN = 0 return = 286364 LEN = 28 OUTPUT = 286364 LEN = 28 Input = <html codeDEM142,50138,350,00
> LEN = 84 IN as <> 0 bs <> 0 Replace = <> LEN = 0 return = <html codeDEM142,50138,350,00
> 286364 LEN = 84 OUTPUT = <html codeDEM142,50138,350,00
> 286364 LEN = 84 Input = <html codeDEM142,50138,350,00
> LEN = 84 IN as <> 0 bs <> 0 Replace = <@> LEN = 1 return = <html codeDEM142,50138,350,00
> 286364 LEN = 84 OUTPUT = <html codeDEM142,50138,350,00
> 286364 LEN = 84 Input = <html codeDEM142,50138,350,00
> LEN = 84 IN as <> 0 bs <> 0 Replace = LEN = 4 return = <html codeDEM142,50138,350,00
> 286364 LEN = 84 OUTPUT = <html codeDEM142,50138,350,00
> 286364 LEN = 84 53 28 41 109 106 28 31 84 84 81 82 83 84 70 98 108 28 84 84 84 #endif