Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VBScript String Clean function - remove or replace illegal characters

40 views
Skip to first unread message

dsoutter

unread,
Dec 20, 2009, 10:50:07 AM12/20/09
to
http://www.code-tips.com/2009/04/vbscript-string-clean-function-remove.html

This article provides a function written in VBScript which removes
illegal characters from a string. The illegal characters are specified
in an array at the beginning of the function. The function is passed
the string which may contain illegal characters, which then processes
the string to remove or replace any illegal characters. The code also
allows you to specify the character or word which will replace
specific illegal characters. The illegal characters provided in the
function are included for processing strings which will become the
filename of a document or list item in SharePoint, which has a number
of characters which are not accepted.

http://www.code-tips.com/2009/04/vbscript-string-clean-function-remove.html

Pegasus [MVP]

unread,
Dec 20, 2009, 12:39:11 PM12/20/09
to

"dsoutter" <dsou...@iinet.net.au> said this in news item
news:f3309e77-8c29-42a3...@y10g2000prg.googlegroups.com...

The code you posted just loops forever. I also wonder if the method you use
is suitable for this purpose since string manipulation is very expensive in
terms of processor time. I suspect that a regular expression might be the
way to go.

Al Dunbar

unread,
Dec 21, 2009, 12:42:14 AM12/21/09
to

"Pegasus [MVP]" <ne...@microsoft.com> wrote in message
news:#moKYtZg...@TK2MSFTNGP06.phx.gbl...

I got dizzy trying to verify the infinite loop thing. You may be right about
regular expressions, however, I would suggest the code (even if it works) is
overly complex. I would have done something more along these lines:

create a dictionary object with the key set to the restricted character
and the value set to what it is to be replaced with
for each key in dicob.keys
filename = replace( filename, key, dicob(key))
next

But, beyond that, I don't see the point of this function. If it processes an
invalid filename, the correct file might not be one with the name
calculated. It might be used to qualify a tentative filename the user
enters, however, it seems to remove valid filename/path characters such as
"." and "\".

/Al

0 new messages