Solved

String replace not working

Posted on 2013-11-05
6
225 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

867 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

21 Experts available now in Live!

Get 1:1 Help Now