;by Einander - Registered PB user
;October 8 - 2003 - PB 3.80
;
Code: Select all
Procedure.s FindMask(Orig$,Msk$)
Shared Compare$
in=FindString(Msk$,"*",1)
If in
LMask$=Left(Msk$,in-1)
RMask$= Mid(Msk$,in+1,Len(Msk$))
in=FindString(Orig$,LMask$,1)
If in
Compare$=Compare$+"*"+LMask$
FindMask(Mid(Orig$,in+2,Len(Orig$)),rMask$)
EndIf
Else
Compare$=Compare$+"*"+Msk$
EndIf
ProcedureReturn Compare$
EndProcedure
;_____________________________________________________________
;
; Use * on mask to replace any text
Original$="This is the original text with included mask fragments"
Mask$="**is*nal*ext wit***uded*ment"
While Left(Mask$,1)="*":Mask$=Mid(Mask$,2,Len(Mask$)):Wend ; cleans mask
While Right(Mask$,1)="*":Mask$=Left(Mask$,Len(Mask$)-1):Wend
If Mask$=Original$
Debug "1 Mask equals Original"
ElseIf Len(Mask$)>Len(Original$)
Debug "0 Mask too long"
Else
Found$=FindMask(Original$,Mask$):Found$=Mid(Found$,2,Len(Found$))
If Found$=Mask$
Debug "1 Found : "+Found$
Else
Debug "0 Not found!"
EndIf
EndIf