Solved

String replace not working

Posted on 2013-11-05
6
223 Views
Last Modified: 2013-11-25
Hi,

I am trying to remove the flash string in the code behind, so the string I want to actually remove is

wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" allowfullscreen="1" play="1" quality="high" loop="0"

I am using the code below but it does not seem to remove it. Would be grateful for any help.
Thanks

Dim strHtml As String
Dim strHtmlReplace As String
 strHtml = pageEditor.Content
  strHtmlReplace = "wmode=""transparent"" type=""application/x-shockwave-flash"" pluginspage=""http://www.macromedia.com/go/getflashplayer"" allowfullscreen=""1"" play=""1"" quality=""high"" loop=""0"""

            strHtml.Replace(strHtmlReplace, " ")
0
Comment
Question by:Soluga
6 Comments
 
LVL 15

Expert Comment

by:unknown_routine
ID: 39624065
I don't see an issue with your code.

where this HTML file is located? is it on web server? if so, a permission issue may prevent you from changing it.  Use strHtml.IndexOf to see if this return a positive value and confirm the permission issue.


 Try to if you can change it if you copy it to a local drive.
0
 
LVL 1

Author Comment

by:Soluga
ID: 39624139
I changed it to .Remove and now I get the error

Message=Conversion from string "wmode="transparent" type="applic" to type 'Integer' is not valid.
0
 
LVL 23

Expert Comment

by:Jens Fiederer
ID: 39624195
I'm hoping you are using the RETURN VALUE of Replace rather than expecting the string to be altered.....Replace returns a new string.
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 1

Author Comment

by:Soluga
ID: 39624201
Doh!

strHtml = strHtml.Replace(strHtmlReplace, "")

Thanks Anyway
0
 
LVL 23

Expert Comment

by:Jens Fiederer
ID: 39624221
Just wanted to be sure.

If that's the case, the only problem I can't actually SEE is whether the white space truly matches...perhaps there are some mismatches between spaces and tabs or newlines.  If you aren't sure about those you could use a pattern replacement where you indicate ANY whitespace with \w
0
 
LVL 5

Accepted Solution

by:
MohitPandit earned 500 total points
ID: 39626422
Hello,

I tried to check aforesaid code and you need to store in variable then you will see that it is doing replace if you are playing with same variable i.e. strHtml

Please find below code:

Dim strHtml As String
        Dim strHtmlReplace As String
        strHtml = "wmode=""transparent"" type=""application/x-shockwave-flash"" pluginspage=""http://www.macromedia.com/go/getflashplayer"" allowfullscreen=""1"" play=""1"" quality=""high"" loop=""0"""
        strHtmlReplace = "wmode=""transparent"" type=""application/x-shockwave-flash"" pluginspage=""http://www.macromedia.com/go/getflashplayer"" allowfullscreen=""1"" play=""1"" quality=""high"" loop=""0"""

        strHtml = strHtml.Replace(strHtmlReplace, " ")
        MessageBox.Show(strHtml)

Open in new window


Best Regards,
Mohit Pandit
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

760 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

23 Experts available now in Live!

Get 1:1 Help Now