''' <summary>
''' Erzeugt aus einem String einen Suchstring der ähnliche Ergebisse findet
''' </summary>
''' <param name="str">Suchstring</param>
''' <param name="EnclosingTags">Soll der String ein führendes und folgendes % haben?</param>
''' <returns>Konvertierter Suchstring</returns>
''' <remarks>Ersetzt Sonderzeichen mit % und setzt ein % zwischen Ziffern/Buchstaben</remarks>
Public Function CreateSimilarSearchString(ByVal str As String, Optional ByVal EnclosingTags As Boolean = False) As String
Dim numbers() As String = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}
Dim IsNumber As Boolean
Dim tmp As String = ""
str = FindAndReplace(str, " ", "%", False)
str = FindAndReplace(str, "-", "%", False)
str = FindAndReplace(str, "_", "%", False)
str = FindAndReplace(str, ".", "%", False)
str = FindAndReplace(str, ",", "%", False)
str = FindAndReplace(str, "+", "%", False)
str = FindAndReplace(str, "(", "%", False)
str = FindAndReplace(str, ")", "%", False)
str = FindAndReplace(str, "*", "%", False)
str = FindAndReplace(str, "'", "%", False)
CreateSimilarSearchString = ""
If Len(str) > 1 Then
tmp = Mid(str, 1, 1)
If ArrExist(numbers, Mid(str, 1, 1), False) > -1 Then
IsNumber = True
Else
IsNumber = False
End If
For i = 2 To Len(str)
If ArrExist(numbers, Mid(str, i, 1), False) > -1 Then
If IsNumber = False Then
tmp += "%" & Mid(str, i, 1)
IsNumber = True
Else
tmp += Mid(str, i, 1)
End If
Else
If IsNumber = True Then
tmp += "%" & Mid(str, i, 1)
IsNumber = False
Else
tmp += Mid(str, i, 1)
End If
End If
Next
End If
If EnclosingTags = True Then tmp = "%" & tmp & "%"
CreateSimilarSearchString = tmp
End Function