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
351 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 53

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

856 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