travisowens Posted August 2, 2004 Posted August 2, 2004 // What am I not seeing here? StreamReader sr = new StreamReader("template.html"); string templateMain = sr.ReadToEnd().ToString(); sr.Close(); // I've tried both ways below, either way nothing happens when I view templateMain templateMain.Replace("<!-- %%HTMLTITLE%% -->","OIN Intranet"); templateMain = Regex.Replace(templateMain, "<!-- %%HTMLTITLE%% -->", "ON Intranet"); Quote Experience is something you don't get until just after the moment you needed it
Administrators PlausiblyDamp Posted August 3, 2004 Administrators Posted August 3, 2004 templateMain = templateMain.Replace("","OIN Intranet"); The string functions return a new string rather than modifying the existing string, you just need to assign that to the original string variable. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
travisowens Posted August 3, 2004 Author Posted August 3, 2004 Even when I create a new string, it doesn't contain the change. string newTemplateMain = templateMain.Replace("<!-- %%HTMLTITLE%% -->","OIN Intranet"); Response.Write(newTemplateMain); PS: When I view the HTML source I specifically know <!-- %%HTMLTITLE%% --> is in there, heck, I copied it from the file and pasted it into my code. Quote Experience is something you don't get until just after the moment you needed it
Arch4ngel Posted August 3, 2004 Posted August 3, 2004 Make sure there's the right amount of "space" in it. A space over and you're not matching. Gimme news Quote "If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown "Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me "A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend. C# TO VB TRANSLATOR
travisowens Posted August 3, 2004 Author Posted August 3, 2004 As I said in my previous post.. I copied the text from the .html file (which I made by hand) so it's EXACT. Quote Experience is something you don't get until just after the moment you needed it
Arch4ngel Posted August 3, 2004 Posted August 3, 2004 You might use the replace function as PlausiblyDamp used it. If it don't work... make sure your templateMain as been filled correctly. Quote "If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown "Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me "A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend. C# TO VB TRANSLATOR
travisowens Posted August 3, 2004 Author Posted August 3, 2004 Actually my code paste was a typo and I was trying templateMain = templateMain.Replace.... I also tried string newTemplateMain = templateMain.Replace.... Ther's something really bizarre going on here. Quote Experience is something you don't get until just after the moment you needed it
travisowens Posted August 3, 2004 Author Posted August 3, 2004 AH HA Egg in my face, it seems my coworker had the wrong string names so the replace was being performed on the wrong data. Guess next time I should check the contents of my string and not assume it actually contains what I thought. ahhh, debugging. Quote Experience is something you don't get until just after the moment you needed it
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.