How can I replace a double quote at the begging of the string and at the end of the string?

I have the following code that I am using to write a string  to an HTML File.  However, when the string is written to the file I get a double quote at the begging of the string and one at the end of the string.  I would like to just replace those two quotes without replacing all the quotes in the entire string.  How would I go about doing this?

This is the line that I am having trouble with.  " Write(4, Replace(strTopEmail.ToString, chr(34), "", 1, 1, CompareMethod.Text) + strBottomEmail + strEmailBody2 + strEmailUnsubScribe + strEmailFooter)"

Thanks  

                          If intCount = 1 Then
                                If File.Exists("\\192.168.0.30\c$\website\LASA2\weeklyemail\default.html") Then
                                    File.Delete("\\192.168.0.30\c$\website\LASA2\weeklyemail\default.html")
                                    FileOpen(4, "\\192.168.0.30\c$\website\LASA2\weeklyemail\default.html", OpenMode.Append, OpenAccess.Write)
                                    Write(4, Replace(strTopEmail.ToString, chr(34)", "", 1, 1, CompareMethod.Text) + strBottomEmail + strEmailBody2 + strEmailUnsubScribe + strEmailFooter)
                                    FileClose(4)
                                Else
                                    FileOpen(4, "\\192.168.0.30\c$\website\LASA2\weeklyemail\default.html", OpenMode.Append, OpenAccess.Write)
                                    Write(4, strTopEmail + strBottomEmail + strEmailBody2 + strEmailUnsubScribe + strEmailFooter)
                                    FileClose(4)
                                End If
                            End If
Richard ComitoDirector of ITAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Fernando SotoRetiredCommented:
Hi GabicusC;

if the following line of code outputs one line to the HTML file, meanning no CrLf in the line:

Replace(strTopEmail.ToString, "„", "", 1, 1, CompareMethod.Text) + strBottomEmail + strEmailBody2 + strEmailUnsubScribe + strEmailFooter

Then this line of code will do what you want.

System.Text.RegularExpressions.Replace(Replace(strTopEmail.ToString, "„", "", 1, 1, CompareMethod.Text) + strBottomEmail + strEmailBody2 + strEmailUnsubScribe + strEmailFooter, "^(")|(")$", "")

I hope that this is of some help.

Fernando

0
appariCommented:

use print function instead of write function.

change

Write(4, strTopEmail + strBottomEmail + strEmailBody2 + strEmailUnsubScribe + strEmailFooter)

to

Print(4, strTopEmail + strBottomEmail + strEmailBody2 + strEmailUnsubScribe + strEmailFooter)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
appariCommented:
from MSDN

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vastmWrite.asp?frame=true

Unlike the Print function, the Write function inserts commas between items and quotation marks around strings as they are written to the file. You don't have to put explicit delimiters in the list.

0
Richard ComitoDirector of ITAuthor Commented:
Thanks fernando for your reply.

However I am getting the following error when I try and use your suggestion.

("Replace" is not a member of RegularExpressions)
0
Richard ComitoDirector of ITAuthor Commented:
Thanks appari,

That did the trick and the expiation helped also.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.