udfStrReplaceWild
str udfStrReplaceWild (str, str, str)
;------------------------------------------------------------------------------------------------------------------------------------------
#DefineFunction udfStrReplaceWild (strMain, strPattern, strUpdate)
If strPattern == "" Then Return strMain
intUpdateLen = StrLen (strUpdate)
intWildPos = StrIndexWild (strMain, strPattern, 1)
While intWildPos
   intWildLen = StrLenWild (strMain, strPattern, intWildPos)
   strMain = StrCat (StrSub (strMain, 1, intWildPos - 1), strUpdate, StrSub (strMain, intWildPos + intWildLen, -1))
   intWildPos = StrIndexWild (strMain, strPattern, intWildPos + intUpdateLen)
EndWhile
Return strMain
;..........................................................................................................................................
; In the wildcard pattern, "*" matches zero or more characters, and "?" matches any one character.
;..........................................................................................................................................
; Adapted from:
;   Conf:  WinBatch Script Exchange
;   From:  kdmoyers admin@guden.com
;   Date:  Friday, April 02, 2004 07:56 PM
;
; Modified by Detlev Dalitz.20040403
;..........................................................................................................................................
#EndFunction
;------------------------------------------------------------------------------------------------------------------------------------------


; Test.

; No pattern, no change.
strMain     = "zsdqwdx.ABC..ashjfhcrzbd.ydfmksdl"
strPattern  = ""
strUpdate   = "#####"
strNew      = udfStrReplaceWild (strMain, strPattern, strUpdate) ; "zsdqwdx.ABC..ashjfhcrebc.ydfmksdl"
Message (strMain, strNew)

; Pattern is matched twice.
strMain     = "zsdqwdx.ABC..ashjfhcrzbd.ydfmksdl"
strPattern  = "z?d"
strUpdate   = "#####"
strNew      = udfStrReplaceWild (strMain, strPattern, strUpdate) ; "#####qwdx.ABC..ashjfhcr#####.ydfmksdl"
Message (strMain, strNew)

; Pattern is matched twice because wildcard search is case insensitive.
strMain     = "zsdqwdx.ABC..ashjfhcrzbd.ydfmksdl"
strPattern  = "a*c"
strUpdate   = "#####"
strNew      = udfStrReplaceWild (strMain, strPattern, strUpdate) ; "zsdqwdx.#####..#####rzbd.ydfmksdl"
Message (strMain, strNew)

Exit
;------------------------------------------------------------------------------------------------------------------------------------------