[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


How to replace a html string?

Posted on 2008-11-06
Medium Priority
Last Modified: 2013-12-17

When I read an upload html file from an email program and send to the recipient, I need to replace a html string insides it

<a href=""><img src="" border="0" valign="top"></a>

<a href="'thomas@yahoo.com'"><img src="" border="0" valign="top"></a>

So that people can click the button to reply and confirm.

Here is the code:

public string SqlEncode(string inStr)
            inStr = inStr.Replace("<a href=""><img src="" border="0" valign="top"></a>", "<a href="yahoo.com'"><img src="" border="0" valign="top"></a>
            return inStr;

But, it does not work.

There are several img links like
img src=""
img src=""
img src=""

Or, I should add \ before all " ?

Please advise
Question by:techques
  • 2
  • 2

Accepted Solution

BToson earned 150 total points
ID: 22901662
If you want to do it that what then why not just do this:
inStr = inStr.Replace(@"<a href="""">", "<a href=\"yahoo.com\">");

You would be better off using a regex to take into account any variations etc.

Author Comment

ID: 22901809
because there are many
<a href="""">

it will replace all with the same url.
there is no id for each  <a href=""""> tag

Expert Comment

ID: 22901865
Then you are better off using regular expression matching and running it against a dictionary using the URL as the key and the e-mail address as the value.  Could end up very messy though...

Author Comment

ID: 22901869
what is the code?

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

872 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