local lcString lcString=[SiteMstr.ccode="01" and inlist(TranMstr.Lender,"jfhjhfjf","fjsdkjfksfj") and PropMstr.LstSlDate>date() and tranmstr.date=date()] lnSec=seconds() oRegExp = CREATEOBJ('VBScript.RegExp') oRegExp.Global = .t. && translate all occurances oRegExp.IgnoreCase = .t. && case insensitive oRegExp.Pattern = '\b\w{4}MSTR\.(.)' && word boundary, followed by 4 word chars && followed by MSTR., followed by any char && other than a newline, remembered as $1 cTranslate = oRegExp.Replace(lcString,'$1') ? cTranslate ?seconds()-lnSec lnSec=seconds() ?STRTRANC(lcString,"sitemstr.","") ?STRTRANC(lcString,"tranmstr.","") ?STRTRANC(lcString,"propmstr.","") ?seconds()-lnSec ******************************************* FUNCTION STRTRANC *-- non case-sensitive string translation ******************************************* PARAMETERS Expc1, Expc2, Expc3, Expn1, Expn2 LOCAL Expr, lnat_pos, lnat_pos2, lnI, lnJ IF EMPTY(m.Expc1).OR.EMPTY(m.Expc2) RETURN m.Expc1 ENDIF m.Expr=m.Expc1 IF TYPE('m.Expn1')#'N' m.Expn1=1 ENDIF IF TYPE('m.Expn2')#'N' m.Expn2=LEN(m.Expc1) ENDIF IF m.Expn1<1.OR.m.Expn2<1 RETURN m.Expc1 ENDIF m.lnI=0 m.lnJ=0 m.lnat_pos2=1 DO WHILE .T. m.lnat_pos=ATC(m.Expc2,SUBSTR(m.Expr,m.lnat_pos2)) IF m.lnat_pos=0 EXIT ENDIF m.lnI=m.lnI+1 IF m.lnI=m.Expn2 EXIT ENDIF m.lnat_pos2=m.lnat_pos+m.lnat_pos2+LEN(m.Expc3)-1 IF m.lnat_pos2>LEN(m.Expr) EXIT ENDIF ENDDO RETURN m.Expr>This beats RegExp for speed by a wide margin. Original Author is Ken Levy. This code was in his original GENSCRNX. The only difference with STRTRAN() is the third parameter is required in this version.
>******************************************* >FUNCTION STRTRANC >*-- non case-sensitive string translation >******************************************* >PARAMETERS Expc1, Expc2, Expc3, Expn1, Expn2 >LOCAL Expr, lnat_pos, lnat_pos2, lnI, lnJ > >IF EMPTY(m.Expc1).OR.EMPTY(m.Expc2) > RETURN m.Expc1 >ENDIF >m.Expr=m.Expc1 >IF TYPE('m.Expn1')#'N' > m.Expn1=1 >ENDIF >IF TYPE('m.Expn2')#'N' > m.Expn2=LEN(m.Expc1) >ENDIF >IF m.Expn1 RETURN m.Expc1 >ENDIF >m.lnI=0 >m.lnJ=0 >m.lnat_pos2=1 >DO WHILE .T. > m.lnat_pos=ATC(m.Expc2,SUBSTR(m.Expr,m.lnat_pos2)) > IF m.lnat_pos=0 > EXIT > ENDIF > m.lnI=m.lnI+1 > IF m.lnI m.lnat_pos2=m.lnat_pos+m.lnat_pos2+LEN(m.Expc2)-1 > LOOP > ENDIF > m.Expr=LEFT(m.Expr,m.lnat_pos+m.lnat_pos2-2)+m.Expc3+; > SUBSTR(m.Expr,m.lnat_pos+m.lnat_pos2+LEN(m.Expc2)-1) > m.lnJ=m.lnJ+1 > IF m.lnJ>=m.Expn2 > EXIT > ENDIF > m.lnat_pos2=m.lnat_pos+m.lnat_pos2+LEN(m.Expc3)-1 > IF m.lnat_pos2>LEN(m.Expr) > EXIT > ENDIF >ENDDO >RETURN m.Expr >