Hi,
I have some code which removes a predetermined set of words such as "to, of , and, or" from strings, The idea being that I can there compare strings such as "15 to 25", "15 and 25", "15 or 25" and they will match.
I'm currently achieving this using the regular expression replace method but I'm finding this is a massive performance hit on my application (approx 300 percent)
I've thought about using split then examining each array element but without a native splice function it seems to me that removing elements from the middle of an array is somewhat tricky.
Should I knuckle down and write a custom splice function or if there a far simpler method that I'm not aware of?
many thanks, see below for RegExp function
Code:
Public Function cleanse(ByRef strInput)
Dim strReturn As String
Dim regRemove As RegExp
Set regRemove = New RegExp
With regRemove
.Pattern = "to|yrs|&|and|or|of"
.IgnoreCase = True
.Global = True
End With
strReturn = regRemove.Replace(strInput, "")
cleanse = strReturn
End Function