I am writing a little function to take an arbitrary string entered into a ‘town’ column in my spreadsheet, remove the special characters, force lower case. This is so I can compare it against known names and return a price in another function that calls this one.
I got it to strip everything but quotes, annoyingly, single quotes sometimes show up in the names I would be putting in that field. While the function is at a point where I can just not touch the quote mark keys when typing in the names, I’d love to know what I need to do to make it pick up the quote marks.
Here is the function, nothing fancy
Function NormalizeTownName(inZone As String) As String
GlobalScope.BasicLibraries.LoadLibrary("Tools")
Dim SafeZoneName As String
SafeZoneName = LCase(inZone)
SafeZoneName = DeleteStr(SafeZoneName, " ")
SafeZoneName = DeleteStr(SafeZoneName, "`")
SafeZoneName = DeleteStr(SafeZoneName, "~")
SafeZoneName = DeleteStr(SafeZoneName, "!")
SafeZoneName = DeleteStr(SafeZoneName, "@")
SafeZoneName = DeleteStr(SafeZoneName, "#")
SafeZoneName = DeleteStr(SafeZoneName, "$")
SafeZoneName = DeleteStr(SafeZoneName, "%")
SafeZoneName = DeleteStr(SafeZoneName, "^")
SafeZoneName = DeleteStr(SafeZoneName, "&")
SafeZoneName = DeleteStr(SafeZoneName, "*")
SafeZoneName = DeleteStr(SafeZoneName, "(")
SafeZoneName = DeleteStr(SafeZoneName, ")")
SafeZoneName = DeleteStr(SafeZoneName, "-")
SafeZoneName = DeleteStr(SafeZoneName, "_")
SafeZoneName = DeleteStr(SafeZoneName, "+")
SafeZoneName = DeleteStr(SafeZoneName, "=")
SafeZoneName = DeleteStr(SafeZoneName, "[")
SafeZoneName = DeleteStr(SafeZoneName, "{")
SafeZoneName = DeleteStr(SafeZoneName, "]")
SafeZoneName = DeleteStr(SafeZoneName, "}")
SafeZoneName = DeleteStr(SafeZoneName, "|")
SafeZoneName = DeleteStr(SafeZoneName, "\")
SafeZoneName = DeleteStr(SafeZoneName, ":")
SafeZoneName = DeleteStr(SafeZoneName, ";")
SafeZoneName = DeleteStr(SafeZoneName, "'")
SafeZoneName = DeleteStr(SafeZoneName, Chr(34))
SafeZoneName = DeleteStr(SafeZoneName, ",")
SafeZoneName = DeleteStr(SafeZoneName, ".")
SafeZoneName = DeleteStr(SafeZoneName, "<")
SafeZoneName = DeleteStr(SafeZoneName, ">")
SafeZoneName = DeleteStr(SafeZoneName, "/")
SafeZoneName = DeleteStr(SafeZoneName, "?")
NormalizeTownName = SafeZoneName
End Function
As a test, I typed in one of the names and peppered it with garbage to see if it worked.
Input:
&%^&%.,,.<>/?;:^He”rvEy `~‘’ “B|}{ay”!
Output:
he”rvey‘“bay”