?
Solved

Vbscript : I want to remove a quote at the beginning of a string an one at the end of a string

Posted on 2011-03-02
3
Medium Priority
?
359 Views
Last Modified: 2012-05-11
How can I achieve this ?
0
Comment
Question by:itbabe
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 12

Accepted Solution

by:
prashanthd earned 668 total points
ID: 35019194
can you give an example of the string?

You can try the following

str=Chr(34) & "This is a quote" &chr(34)

WScript.Echo Replace(str,Chr(34),"")
0
 
LVL 56

Assisted Solution

by:Bill Prew
Bill Prew earned 668 total points
ID: 35020663
Something like this will work:

'Strip single quote from left of string
If Left(str,1) = "'" Then
  str = Right(str, Len(str)-1)
End If
'Strip single quote from right of string
If Right(str,1) = "'" Then
  str = Left(str, Len(str)-1)
End If

Open in new window

~bp
0
 
LVL 65

Assisted Solution

by:RobSampson
RobSampson earned 664 total points
ID: 35022436
Bill is right.  That's for a single quote, if you wanted to remove a double quote, use

strText = """My Text"""
If Left(strText, 1) = """" Then strText = Mid(strText, 2)
If Right(strText, 1) = """" Then strText = Left(strText, Len(strText) - 1)

Open in new window


Regards,

Rob.
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently I finished a vbscript that I thought I'd share.  It uses a text file with a list of server names to loop through and get various status reports, then writes them all into an Excel file.  Originally it was put together for our Altiris server…
This is an addendum to the following article: Acitve Directory based Outlook Signature (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24950055.html) The script is fine, and works in normal client-server domains…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses
Course of the Month15 days, 7 hours left to enroll

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question