'  FF_REPLACEANY
'  指定的字符串中，取代任何在matchPattern字符串指定的个别字符的所有匹配项。
'FF_ReplaceAny(原字符,替换的字符表,被替换的字(必须是1个字符，空字符出错)
'  Function FF_ReplaceAny( ByRef sMainString   as String, _
'                          ByRef sMatchPattern as String, _
'                          ByRef sReplaceWith  as String _
'                          ) as String

Function FF_ReplaceAny( ByRef sMainString   as String, _
                        ByRef sMatchPattern as String, _
                        ByRef sReplaceWith  as String _
                        ) as String

    Dim nLenMain    as Integer = Len(sMainString)
    Dim nLenMatch   as Integer = Len(sMatchPattern)
    Dim nLenReplace as Integer = Len(sReplaceWith)
    
    Dim s as String   
    Dim y as Integer
    Dim i as Integer 

    ' Note: sReplaceWith must be one character in size because this function
    '       replaces individual characters rather than words.
    If nLenReplace <> 1 Then Return sMainString
    If nLenMain  = 0 Then Return sMainString
    If nLenMatch = 0 Then Return sMainString
    
    s = sMainString   ' make a default return copy of the string
    
    ' Get each character in the sMatchPattern string and look for it in sMainString
    ' Using string pointer indexing for speed.
    For y = 0 To nLenMatch - 1
       For i = 0 To nLenMain - 1
          If sMatchPattern[y] = sMainString[i] Then
             s[i] = sReplaceWith[0]
          End If
       Next
    Next
    
    Function =  s

End Function

''
''  FF_REPLACEANY
''  Within a specified string, replace all occurrences of any of the individual characters
''  specified in the MatchPattern string.
''
''  This function is case-sensitive.      
''  sReplaceWidth must be a single character. This function does not replace words therefore
''  MainString will be the same size - it will not shrink or grow.
''