Hi there,
If I have a string var, strFoo that contains double-quotes such that it
looks like this: I "love" VB
What do I pass into the "replace" method to replace the double-quotes with
something else?
strFoo = strFoo.replace( ???,""")
In other words, what would I pass in inplace of the ??? above to get rid of
any double quotes in the string var strFoo?
Thanks,
Kevin 4 24358
You have to escape the " character, that's all.
The way to do that is replace instances of " with "".
Sample code -
Try
Dim str As String = "I ""love"" VB"
Console.WriteLi ne(str)
Console.WriteLi ne(str.Replace( """", ""))
Catch ex As Exception
Console.Write(e x.ToString())
Finally
Console.Read()
End Try
- Sahil Malik
You can reach me thru my blog at http://www.dotnetjunkies.com/weblog/sahilmalik
"Kevin Thomas" <Ke***@FakeEmai lAddresses.com> wrote in message
news:%2******** *******@TK2MSFT NGP15.phx.gbl.. . Hi there,
If I have a string var, strFoo that contains double-quotes such that it looks like this: I "love" VB
What do I pass into the "replace" method to replace the double-quotes with something else?
strFoo = strFoo.replace( ???,""")
In other words, what would I pass in inplace of the ??? above to get rid
of any double quotes in the string var strFoo?
Thanks,
Kevin
"Kevin Thomas" <Ke***@FakeEmai lAddresses.com> schrieb: If I have a string var, strFoo that contains double-quotes such that it looks like this: I "love" VB
What do I pass into the "replace" method to replace the double-quotes with something else?
strFoo = strFoo.replace( ???,""")
'... = strFoo.Replace( """", """)'.
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Thanks everyone for your quick response.
The funny thing here is that I was escaping the " with """" but when viewing
my output in IE, the browser was itself changing the " back into " for
easy viewing, thus convincing me that it was imposible to replace a
double-quote. Once I viewed source in IE, I saw that the double-quote was
getting replaced.
Thanks again!
Kevin
"Sahil Malik" <co************ *****@nospam.co m> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. .. You have to escape the " character, that's all.
The way to do that is replace instances of " with "".
Sample code -
Try Dim str As String = "I ""love"" VB" Console.WriteLi ne(str) Console.WriteLi ne(str.Replace( """", "")) Catch ex As Exception Console.Write(e x.ToString()) Finally Console.Read() End Try - Sahil Malik You can reach me thru my blog at http://www.dotnetjunkies.com/weblog/sahilmalik
"Kevin Thomas" <Ke***@FakeEmai lAddresses.com> wrote in message news:%2******** *******@TK2MSFT NGP15.phx.gbl.. . Hi there,
If I have a string var, strFoo that contains double-quotes such that it looks like this: I "love" VB
What do I pass into the "replace" method to replace the double-quotes with something else?
strFoo = strFoo.replace( ???,""")
In other words, what would I pass in inplace of the ??? above to get rid of any double quotes in the string var strFoo?
Thanks,
Kevin
Kevin,
In addition to the other comments, you can use also ControlChars.Qu ote. strFoo = strFoo.replace( ControlChars.Qu ote,""")
However it appears that you are doing something with HTML or XML, rather
then attempting to use String.Replace to create well formed HTML or XML I
would use one of the Framework classes that already do this.
Such as:
HttpUtility.Htm lEncode & HttpUtility.Htm lDecode
HttpServerUtili ty.HtmlEncode & HttpServerUtili ty.HtmlDecode
XmlTextWriter & XmlTextReader
Depending on what you are really trying to do there may be other more
appropriate classes.
Hope this helps
Jay
"Kevin Thomas" <Ke***@FakeEmai lAddresses.com> wrote in message
news:%2******** *******@TK2MSFT NGP15.phx.gbl.. . Hi there,
If I have a string var, strFoo that contains double-quotes such that it looks like this: I "love" VB
What do I pass into the "replace" method to replace the double-quotes with something else?
strFoo = strFoo.replace( ???,""")
In other words, what would I pass in inplace of the ??? above to get rid of any double quotes in the string var strFoo?
Thanks,
Kevin This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: middletree |
last post by:
What's wrong with this code?
strLongDesc =
Replace(Replace(Replace(Replace(Trim(Request.Form("LongDesc")),"'","''"),vbC
rLf,"<br>"),"<",<),"<",>)
Background:
This field is a textarea, and I needed to account for apostrophes, which I
had already done, and replaced line breaks with html line breaks on my page
which displays this stuff. That works fine. But then a user entered this
|
by: Roy Adams |
last post by:
Hi group I'm having trouble using the replace command
Here's my code below
<%@LANGUAGE="JAVASCRIPT" CODEPAGE="1252"%>
<!--#include file="../../Connections/conn.asp" -->
<%
if( String(Request.Form("ProductName")) != "undefined" ){//formfield
|
by: Shawn |
last post by:
Hi.
I have a form with a couple of text fields where users can enter some data.
The data is stored in an access DB.
the problem is that whenever a user enters " in a textbox some of the text
dissapears.
Example:
If the users writes: I have a 17" LCD for sale
Then this is what is stored in the DB: I have a 17
How can I store the whole text in my DB? Or how can I remove it altogether?
|
by: P1ayboy |
last post by:
I have a string that contains double quotes.
I need to replace these, but how can i do it as the code would be:
replace(string,""","")
Is there a way of breaking out of the double quotes?
thanks
|
by: Christopher Benson-Manica |
last post by:
Why doesn't this replace all double quotes in a string with the letter
Q?
source.replace( /"(*)"/g, "Q$1Q" );
--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
| |
by: G. |
last post by:
This is an obvious bug in the String.Replace function:
//load a XML string into a document
XmlDocument doc = new XmlDocument();
doc.LoadXml("<test id='' />");
//Obtain the string again...Converts my '' to ""...strange, but ok.
String strXML = doc.OuterXml;
//trying to convert back the single quotes to double quotes
|
by: Derek Martin |
last post by:
I have an object with several string elements that I would like to check for
invalid characters in the properties of each element. Can I use
string.replace to do that or is there a better alternative to this?
Example:
Property orgname() As String
Get
orgname = m_orgname
End Get
Set(ByVal Value As String)
|
by: jarod1701 |
last post by:
Hi,
i'm currently trying to replace an unknown string using regular
expressions.
For example I have:
user_pref("network.proxy.http", "server1")
What do I have to do to replace the "server1" part (which could be
|
by: Neeta |
last post by:
Hi All,
I am having problem using Regex.Replace.I am trying to search all the
strings present in a .cs file and replace it with a different string .I am
doing this by searching all the code which comes under ""(double quotes).
Code for Replacement:
System.Text.RegularExpressions.Regex.Replace(str, "\"" + fstring + "\"",
resxName + "." + ResxItemName);
|
by: =?Utf-8?B?R2Vvcmdl?= |
last post by:
Hello,
I have some XML that is returned to my application from another vendor that
I cannot change before it gets to me. I can only alter it after it gets to my
application. That being said, I am having a problem loading the XML correctly
into my app.
Here is the code:
====================================
Dim sPaymentXML as String
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |