ANmaSearch_ApostropheFriends

Searches for string inside string with apostrophe variations conversion

CodeFunctionName
What is this?

Public

Tested

Original Work
Function ANmaSearch_ApostropheFriends(SearchFor, SearchIn, Optional StartSearchFrom = 1)
    ' Searches for string inside string with apostrophe variations conversion
    ' if single quote was found in SearchFor
    '     it will try searching all possible translation in SearchIn of it in HTML codes
    '     like        '    '            ‘        ’
    '
    ' Returns the place where SearchFor found in SearchIn
    ' Needs VBInstr
    Rett = 0
    If StartSearchFrom = 0 Then StartSearchFrom = 1
    Found1 = VBInstr(SearchFor, SearchIn, StartSearchFrom) ' Search with no quote expected
    If Found1 > 0 Then Goto ByeBye
    If VBInstr("'", SearchFor) > 0 Then ' Found single quote in SearchFor, let us do the searching for it or its friends
        ' Searching for single quote uses replace
        Found1 = VBInstr(Replace(SearchFor, "'", "'"), SearchIn, StartSearchFrom)
        If Found1 > 0 Then Goto ByeBye
        Found1 = VBInstr(Replace(SearchFor, "'", "'"), SearchIn, StartSearchFrom)
        If Found1 > 0 Then Goto ByeBye
        Found1 = VBInstr(Replace(SearchFor, "'", "’"), SearchIn, StartSearchFrom)
        If Found1 > 0 Then Goto ByeBye
        Found1 = VBInstr(Replace(SearchFor, "'", "‘"), SearchIn, StartSearchFrom)
        If Found1 > 0 Then Goto ByeBye
        Found1 = VBInstr(Replace(SearchFor, "'", "‘"), SearchIn, StartSearchFrom)
        If Found1 > 0 Then Gotot ByeBye
        Found1 = VBInstr(Replace(SearchFor, "'", "’"), SearchIn, StartSearchFrom)
        ' We tried our best, do we have more firends?
        ' ...
    End If
    ByeBye:
    ANmaSearch_ApostropheFriends = Found1
End Function

SearchFor, SearchIn, Optional StartSearchFrom = 1

Views 149

Downloads 61

CodeID
DB ID