Windows Vista Forums

VBScript String Clean function - remove or replace illegal characters

  1. #1


    dsoutter Guest

    VBScript String Clean function - remove or replace illegal characters

    http://www.code-tips.com/2009/04/vbs...on-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/vbs...on-remove.html

      My System SpecsSystem Spec

  2.   


  3. #2


    Pegasus [MVP] Guest

    Re: VBScript String Clean function - remove or replace illegal characters



    "dsoutter" <dsoutter@newsgroup> said this in news item
    news:f3309e77-8c29-42a3-8261-6d9d66d81ad6@newsgroup

    > http://www.code-tips.com/2009/04/vbs...on-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/vbs...on-remove.html
    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.


      My System SpecsSystem Spec

  4. #3


    Al Dunbar Guest

    Re: VBScript String Clean function - remove or replace illegal characters



    "Pegasus [MVP]" <news@newsgroup> wrote in message
    news:#moKYtZgKHA.1536@newsgroup

    >
    >
    > "dsoutter" <dsoutter@newsgroup> said this in news item
    > news:f3309e77-8c29-42a3-8261-6d9d66d81ad6@newsgroup

    >> http://www.code-tips.com/2009/04/vbs...on-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/vbs...on-remove.html
    >
    > 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.
    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



      My System SpecsSystem Spec


VBScript String Clean function - remove or replace illegal characters
Similar Threads
Thread Forum
VBScript String Replace - Remove / Replace Characters in String VB Script
VBScript String Clean function - remove or replace a set ofcharacters VB Script
Remove characters in a string VB Script
Replace special characters VB Script
Replace special characters in filenames - how? PowerShell