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
350 Views
Last Modified: 2012-05-11
How can I achieve this ?
0
Comment
Question by:itbabe
3 Comments
 
LVL 12

Accepted Solution

by:
prashanthd earned 167 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 52

Assisted Solution

by:Bill Prew
Bill Prew earned 167 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 166 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

932 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now