How can I replace script contents of html in a StringBuilder

448 views Asked by At

I have a HTML page in my .Net project in that I have one script section

<script language="javascript" type="text/javascript">
    s.property1="|*|property1|*|"
    s.property2="|*|property2|*|"
<script>

In the c# code I'm reading the html file and replacing the "| * |property1| *|" values like below

StringBuilder siteCode = new StringBuilder();
//code to append html file to StringBuilder(siteCode)

if(xyz!=null)
{
    siteCode.Replace("|*|property1|*|", xyz);
}
else
{
    //remove s.property1="|*|property1|*|"
}

How can I remove s.property1="||property1||" from StringBuilder(siteCode)?

1

There are 1 answers

0
Nic On BEST ANSWER

Just use the StringBuilder Replace method?

siteCode.Replace("s.property1=\"||property1||\"", "");