C
Colin Steadman
I'm trying to setup a function that will remove any
character from a string which is NOT either a space, a-z
or 0-9. I'm using a Regular Expression to do this.
I'm almost there but I cant get the pattern right. After
trying all sorts of crazy patterns the closest I've come
is with this simplistic attempt:
Function ripOutSpecialCharacters(strComment)
Set re = New RegExp
re.pattern = "\W"
re.global = True
ripOutSpecialCharacters = re.replace(strComment, " ")
Set re = Nothing
End Function
This is almost what I want, but if I run it on a string
like this -
Its that special blend and
roast.
I end up with this -
Its that special blend and roast.
^^ ie two spaces here.
I'm really struggling to get the pattern right, can anyone
offer any help on this?
TIA,
Colin
character from a string which is NOT either a space, a-z
or 0-9. I'm using a Regular Expression to do this.
I'm almost there but I cant get the pattern right. After
trying all sorts of crazy patterns the closest I've come
is with this simplistic attempt:
Function ripOutSpecialCharacters(strComment)
Set re = New RegExp
re.pattern = "\W"
re.global = True
ripOutSpecialCharacters = re.replace(strComment, " ")
Set re = Nothing
End Function
This is almost what I want, but if I run it on a string
like this -
Its that special blend and
roast.
I end up with this -
Its that special blend and roast.
^^ ie two spaces here.
I'm really struggling to get the pattern right, can anyone
offer any help on this?
TIA,
Colin