Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Trouble using "

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,61315
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Trouble using "
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Trouble using " - 6/12/2008 7:33:39 AM   
  sforesman

 

Posts: 2
Score: 0
Joined: 6/12/2008
Status: offline
I've been asked to correct a vbs we have.  I don't have much experience with vbs, so I came here.

This function takes a string and takes the illegal characters out, so it can be used as a file name later.  I need to add " to this list.  I thought this was taken care of with chr(34), but the " is still making its way through to the file name, which doesn't let us cope to the unix server.




Function StripIllegalChar(strInput)

'***************************************************
'Simple function that removes illegal file system
'characters.
'***************************************************

Set RegX = New RegExp

RegX.pattern = "[\" & chr(34) & "\!\#\$\%\^\&\*\(\)\=\+\|\[\]\{\}\`\'\;\:\<\>\?\/\,]"
RegX.IgnoreCase = True
RegX.Global = True

StripIllegalChar = RegX.Replace(strInput, "")

Set RegX = nothing

End Function



Thanks in advance for any help.
 
 
Post #: 1
 
 RE: Trouble using " - 6/12/2008 8:06:51 AM   
  dm_4ever


Posts: 2434
Score: 38
Joined: 6/29/2006
From: Orange County, California
Status: offline
Seems to catch " for me....

oh....I would do this if there were so many exclusions..


"[^A-Z0-9]" 'anything not part of characters you consider "legal"

< Message edited by dm_4ever -- 6/12/2008 8:16:23 AM >


_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to sforesman)
 
 
Post #: 2
 
 RE: Trouble using " - 6/13/2008 1:30:45 AM   
  DBSmith

 

Posts: 6
Score: 0
Joined: 5/17/2006
Status: offline
Take a look and see what ascii values you are actually seeing. There is a right " AND a left " that are different chr(values). I had this problem a while back doing the same thing.

(in reply to sforesman)
 
 
Post #: 3
 
 RE: Trouble using " - 6/13/2008 1:43:03 AM   
  DBSmith

 

Posts: 6
Score: 0
Joined: 5/17/2006
Status: offline
Some quick and dirty code that may help explain what I'm talking about.

' "notepad"
' "MSWord"
strnotepadText = Chr(34)&"notepad"&Chr(34)
   For i = 1 To Len(strnotepadText)
    WScript.Echo "The character at pos " & i & " is " & Mid(strnotepadText, i, 1) & " the ANSI value is " & Asc(Mid(strnotepadText, i, 1))  
   Next
WScript.Echo (strnotepadText)
WScript.Echo
strMSWordText = Chr(147)&"MSWord"&Chr(148)
   For i = 1 To Len(strMSWordText)
    WScript.Echo "The character at pos " & i & " is " & Mid(strMSWordText, i, 1) & " the ANSI value is " & Asc(Mid(strMSWordText, i, 1))  
   Next
WScript.Echo (strMSWordText)

(in reply to sforesman)
 
 
Post #: 4
 
 RE: Trouble using " - 6/13/2008 2:49:01 AM   
  sforesman

 

Posts: 2
Score: 0
Joined: 6/12/2008
Status: offline
Thanks, good idea on how to get around it, everything is working fine now.

(in reply to dm_4ever)
 
 
Post #: 5
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Trouble using " Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts