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
356 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 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 55

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

691 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