Regex eliminates hyphen on clicking complete button
On running my code in the browser i have some templates on clicking those templates below code gets executedprotected void ShowTemplate(byte[] Template)
{
CKEditor1.Text = "";
byte[] excelContents = Template;
File.WriteAllBytes(Server.MapPath("~/Doc/") + "Demo.Docx", excelContents);
string path = Server.MapPath("~/Doc/") + "Demo.html";
document.SaveToFile(path, Spire.Doc.FileFormat.Html);
string html = File.ReadAllText(path);
string[] splits = Request.Url.AbsoluteUri.Split('/');
string url = string.Empty;
if (splits.Length >= 2)
{
url = splits[0] + "//";
for (int i = 2; i < splits.Length - 1; i++)
{
url += splits[i];
url += "/";
}
}
string ImgPath = url + "Doc\\Demo_images";
html = html.Replace("Demo_images", ImgPath);
string STR = html;
string STRFirst = "<title>";
string STRLast = "</title>";
string FinalString;
int Pos1 = STR.IndexOf(STRFirst) + STRFirst.Length;
int Pos2 = STR.IndexOf(STRLast);
FinalString = STR.Substring(Pos1, Pos2 - Pos1);
if (FinalString.Length > 0)
{ html = html.Replace(FinalString, ""); }
string str = @"""0""";
string str1 = "<table border=" + str + " ";
html = html.Replace("<table", str1);
html = html.Replace("border-top-color:", "\"><hr /><border-top-color:");
CKEditor1.Text = html;
String TCount = Regex.Replace(CKEditor1.Text, @"<[^>]+>| |"|'| |\n|\r|\t|–|Start here|text here", "");
ViewState["TCount"] = TCount;
}
In this method the text that i get at TCount while debugging iswhen i click on template is
FILE NOTEClient/Ref:Surname/Date:15 July 2016Matter:Attended by:LCTime engaged:1 hour – .Time engaged – 1 hour
After clicking the template user can see an editor where he can give the text an click on submit button if the user does not eneter any text in the editor and click on submit button i should get the word count as zero but i am getting word count as -2 because when i click on complete button the text that i get at TCount in the first method is same as second method but it eliminates hyphens as two hyphens are eliminated instead of getting zero as word count i am getting -2 as word count how ca i display hyphens in my second method also near count.
protected void btnCompleteTranscription_Click(object sender, EventArgs e)
{
string count = Regex.Replace(CKEditor1.Text, @"<[^>]+>| |"|'| |\n|\r|\t|–|Start here|text here", "");
string Text = "<html><body>" + CKEditor1.Text + "</body></html>";
Text = Text.Replace("<", "<");
Text = Text.Replace(">", ">");
Text = Text.Replace(">style=", "><span style=");
Text = Text.Replace("<span <", "<span></span> <");
Text = Text.Replace("<p <", "<p> <");
Text = Text.Replace("<del", "<s><span");
Text = Text.Replace("</del", "</s></span");
Text = Text.Replace(" ", " ");
Text = Text.Replace("<s style=", "<s><span style=");
Text = Text.Replace("<p <", "<p style=\"text-align:justify\"><span><");
Text = Text.Replace(">font-size:14pt", " "); ;
CKEditor1.Text = Text;
string TCount = ViewState["TCount"].ToString();
int TLength=(Int32)ViewState["TCount"].ToString().Length;
int WCount = (Int32)count.Length - TLength;
string datefolder = DateTime.Today.Month.ToString().Length < 2 ? "0" + DateTime.Today.Month.ToString() : DateTime.Today.Month.ToString();
datefolder += DateTime.Today.Day.ToString().Length < 2 ? "0" + DateTime.Today.Day.ToString() : DateTime.Today.Day.ToString();
datefolder += DateTime.Today.Year.ToString();
string ComparePath = Server.MapPath("~/GDocs/" + Session["uid"].ToString().ToUpper() + "/Transcribed/" + datefolder);
if (!System.IO.Directory.Exists(ComparePath))
{
System.IO.Directory.CreateDirectory(ComparePath);
}
using (System.IO.StreamWriter file = new System.IO.StreamWriter(ComparePath + @"\" + ViewState["af"].ToString().Replace(".wav", "") + ".Doc"))
{
file.Write(Text);
}
}
when i click on complete button the text that i get near count is
FILE NOTEClient/Ref:Surname/Date:15 July 2016Matter:Attended by:LCTime engaged:1 hour .Time engaged 1 hour
**If we notice those two sentences hyphens gets eliminated in second method but i need to display hyphens also how can i do this**