locked
Deleting specific HTML formatiing using C# in Script Task SSIS RRS feed

  • Question

  • User-2019470928 posted

    /* Microsoft SQL Server Integration Services Script Component
    * Write scripts using Microsoft Visual C# 2008.
    * ScriptMain is the entry point class of the script.*/
    // C# code
    using System;
    using System.Data;
    using System.Text.RegularExpressions; // Added
    using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
    using Microsoft.SqlServer.Dts.Runtime.Wrapper;

    [Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
    public class ScriptMain : UserComponent
    {
    // Method that will be executed for each row.
    public override void Input0_ProcessInputRow(Input0Buffer Row)
    {
    // Replace the value of the message column
    if (!string.IsNullOrEmpty(Row.Notes))
    {
    string strRowNotes = RemoveHtml(Row.Notes);
    if (!string.IsNullOrEmpty(strRowNotes))
    {
    // Replace the value of the message column
    Row.Notes = RemoveHtml(Row.Notes)
    .Replace(" ", " ")
    .Replace("&", " ").Replace("-->", " ").Replace(""", "\"")
    .Replace("&lt;", "<")
    .Replace(": YES", ": YES ").Replace(": NO", ": NO ")
    .Replace("<p class=\"MsoNormal \"", " ")
    .Replace("<table cellspacing="," ")
    ;
    }
    else
    Row.Notes = "";
    }
    else
    Row.Notes = "";

    }


    // A string method that removes html tags
    // with a regex pattern
    public String RemoveHtml(String message)
    {
    // The pattern for a html tag

    String htmlTagPattern = "<(.|\n)*?>";
    // string htmlTagPattern = "/(<[^\n]+)[^>]*(>)/?>";
    ///"/(<[^\n]+)[^>]*(>)/";
    /// ///"<(.|\n)*?>"
    /// ///<[^>]*>
    /// ///"(?<=<[^>]*)&nbsp"
    // Create a regex object with the pattern
    Regex objRegExp = new Regex(htmlTagPattern);
    // Replace html tag by an empty string

    message = objRegExp.Replace(message, String.Empty);

    // Return the message without html tags
    return message;

    }

    }

    NEED TO REMOVE BELOW FORMAT AND REPLACE WITH ""

    <p class="MsoNormal" align="center" style="margin: 0in 0in 0pt; text-align: center"><span style="font-family: Arial"><font size="3"> Submitted<o:p></o:p></font></span></p><p class="MsoNormal" align="center" style="margin: 0in 0in 0pt; text-align: center"><o:p><font face="Times New Roman" size="3">&nbsp;</font></o:p></p><div align="center"><table class="MsoTableGrid" cellspacing="0" cellpadding="0" border="1" style="border-right: medium none; border-top: medium none; border-left: medium none; border-bottom: medium none; border-collapse: collapse; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 480; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext"><tbody><tr style="height: 0.15in; mso-yfti-irow: 0; mso-yfti-firstrow: yes">

    Monday, April 15, 2013 4:08 PM

Answers

  • User281315223 posted

    If the input is the same as the code that you just provided (the massive block of &nbsp; ) and you want to strip out everything but the actual words (so remove all of the HTML tags and all of the instances of &nbsp;) then the following Regular Expression should match both of those : 

    <[^>]*>|&nbsp;

    It will match any HTML tag and explicitly any &nbsp; so that you can remove them within your RemoveHtml method : 

    public string RemoveHtml(String message)
    {
            // Your Pattern to strip all HTML and &nbsp;
            string htmlTagPattern = @"<[^\>]*>|&nbsp;";
            
            // Create a regex object with the pattern 
            Regex objRegExp = new Regex(htmlTagPattern);
            
            // Replace html tag by an empty string
            message = objRegExp.Replace(message, String.Empty);
            
            // Return the message without html tags
            return message;
    }

    However, the previous code that you were using (to initially strip all of the HTML tags) and then use the chained Replace statements should have handled this for you.

    Have you placed a breakpoint within this code (if possible) to see if you can determine where the problem is occuring at?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 16, 2013 12:56 PM
  • User1508394307 posted

    jampa09

    Hi All- the below format is also putting out empty spaces " ", can i clean this

    myString = Regex.Replace(myString, @"\s+", " ");
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 16, 2013 3:02 PM

All replies

  • User1508394307 posted

    What is the problem exactly?

    I think 

    String htmlTagPattern = "<(.|\n)*?>";
    Regex objRegExp = new Regex(htmlTagPattern);
    message = objRegExp.Replace(message, String.Empty);

    should remove all html tags from your text above, so you will get only " Submitted".

    Monday, April 15, 2013 6:36 PM
  • User-2019470928 posted

    Hey Smirnov,

    The code is putting out blanks whenever i encounter this pattern

    <class="MsoNormalalign="centerstyle="margin: 0in 0in 0pt; text-align: center"><span style="font-family: Arial"><fontsize="3"> Submitted<o:p></o:p></font></span></p><p class="MsoNormalalign="centerstyle="margin: 0in 0in 0pt; text-align: center"><o:p><font face="Times New Romansize="3">&nbsp;</font></o:p></p><div align="center"><tableclass="MsoTableGridcellspacing="0cellpadding="0border="1style="border-right: medium none; border-top: medium none; border-left: medium none; border-bottom: medium none; border-collapse: collapse; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 480; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext"><tbody><tr style="height: 0.15in; mso-yfti-irow: 0; mso-yfti-firstrow: yes">

    <table class="MsoTableGrid" cellspacing="0" cellpadding="0" border="1" style="border-right: medium none; border-top: medium none; border-left:
    medium none; border-bottom: medium none; border-collapse: collapse; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 480; mso-padding-alt:
    0in 5.4pt
    0in 5.4pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext">
    <tbody><tr style="height: 0.15in; mso-yfti-irow: 0; mso-yfti-firstrow: yes">

    I need to get only "submitted "

    Monday, April 15, 2013 7:15 PM
  • User281315223 posted

    Try using the following Regular Expression to strip out your HTML tags : 

    <[^\>]*>

    Example : 

    //Your Original String
    string yourHTML = @"<p class='MsoNormal' align='center' style='margin: 0in 0in 0pt; text-align: center'><span style='font-family: Arial'><font size='3'> Submitted<o:p></o:p></font></span></p><p class='MsoNormal' align='center' style='margin: 0in 0in 0pt; text-align: center'><o:p><font face='Times New Roman' size='3'>&nbsp;</font></o:p></p><div align='center'><table class='MsoTableGrid' cellspacing='0' cellpadding='0' border='1' style='border-right: medium none; border-top: medium none; border-left: medium none; border-bottom: medium none; border-collapse: collapse; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 480; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext'><tbody><tr style='height: 0.15in; mso-yfti-irow: 0; mso-yfti-firstrow: yes'>";
    
    //Replaces all of the HTML tags yielding "submitted&nbsp;" 
    yourHTML = Regex.Replace(yourHTML,@"<[^\>]*>","");

    (Aren't Microsoft Word styles fun?)

    Monday, April 15, 2013 7:30 PM
  • User-2019470928 posted

    Hello,

    It is still putting out empty spaces. when i see the following pattern. I have tried the above expression but no luck 


    - <p class="MsoNormal" align="center" style="margin: 0in 0in 0pt; text-align: center">
    <span style="font-family: Arial"><font size="3">Submitted<o:p></o:p></font></span></p>
    <p class="MsoNormal" align="center" style="margin: 0in 0in 0pt; text-align: center"><o:p>
    <font face="Times New Roman" size="3">&nbsp;</font></o:p></p><div align="center">
    <table class="MsoTableGrid" cellspacing="0" cellpadding="0" border="1" style="border-right: medium none; border-top: medium none; border-left:
    medium none; border-bottom: medium none; border-collapse: collapse; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 480;
    mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext">
    <tbody><tr style="height: 0.15in; mso-yfti-irow: 0; mso-yfti-firstrow: yes"><td valign="top" width="295" style="border-right:
    windowtext 1pt solid; padding-right: 5.4pt; border-top: windowtext 1pt solid; padding-left: 5.4pt; padding-bottom: 0in; border-left:
    windowtext 1pt solid; width: 221.5pt; padding-top: 0in; border-bottom: windowtext 1pt solid; height: 0.15in; background-color:
    transparent; mso-border-alt: solid windowtext .5pt"><p class="MsoNormal" align="right" style="margin: 0in 0in 0pt; text-align: right">
    <span style="font-size: 8pt; font-family: Verdana">
    <o:p></o:p></span></p></td><td valign="top" width="295" style="border-right: windowtext 1pt solid; padding-right: 5.4pt;
    border-top: windowtext 1pt solid; padding-left: 5.4pt; padding-bottom: 0in; border-left: #d4d0c8; width: 221.3pt; padding-top: 0in;
    border-bottom: windowtext 1pt solid; height: 0.15in; background-color: transparent; mso-border-alt: solid windowtext .5pt;
    mso-border-left-alt: solid windowtext .5pt"><p class="MsoNormal" style="margin: 0in 0in 0pt"><span style="font-size: 8pt; font-family: Verdana">
    <o:p></o:p></span></p></td></tr><tr style="height: 0.15in; mso-yfti-irow: 1">
    <td valign="top" width="295" style="border-right: windowtext 1pt solid; padding-right: 5.4pt; border-top: #d4d0c8; padding-left: 5.4pt;
    padding-bottom: 0in; border-left: windowtext 1pt solid; width: 221.5pt; padding-top: 0in; border-bottom: windowtext 1pt solid; height:
    0.15in; background-color: transparent; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt">
    <p class="MsoNormal" align="right" style="margin: 0in 0in 0pt; text-align: right"><span style="font-size: 8pt; font-family: Verdana">
    <o:p></o:p></span></p></td><td valign="top" width="295" style="border-right: windowtext 1pt solid; padding-right: 5.4pt; border-top: #d4d0c8;
    padding-left: 5.4pt; padding-bottom: 0in; border-left: #d4d0c8; width: 221.3pt; padding-top: 0in; border-bottom: windowtext 1pt solid; height:
    0.15in; background-color: transparent; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt:
    solid windowtext .5pt"><p class="MsoNormal" style="margin: 0in 0in 0pt"><span style="font-size: 8pt; font-family: Verdana">

    Monday, April 15, 2013 7:59 PM
  • User281315223 posted

    I just used the exact text that you provided and the same Regular Expression to replace it and recieved the following as my output : 

    Submitted&nbsp;

    using the a modifed version of the function you mentioned earlier : 

    public String RemoveHtml(String message)
    {
           //Creates your Regular Expression along with the appropriate pattern
           string htmlTagPattern = @"<[^\>]*>";
           Regex objRegExp = new Regex(htmlTagPattern);
            
           //Performs your Replace
           message = objRegExp.Replace(message, String.Empty);
    
            // Return the message without html tags
            return message;
    }

    Example

    //Your HTML Example
    string yourHTML = @"<p class='MsoNormal' align='center' style='margin: 0in 0in 0pt; text-align: center'><span style='font-family: Arial'><font size='3'>Submitted<o:p></o:p></font></span></p><p class='MsoNormal' align='center' style='margin: 0in 0in 0pt; text-align: center'><o:p><font face='Times New Roman' size='3'>&nbsp;</font></o:p></p><div align='center'><table class='MsoTableGrid' cellspacing='0' cellpadding='0' border='1' style='border-right: medium none; border-top: medium none; border-left:medium none; border-bottom: medium none; border-collapse: collapse; mso-border-alt: solid windowtext .5pt; mso-yfti-tbllook: 480; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-border-insideh: .5pt solid windowtext; mso-border-insidev: .5pt solid windowtext'><tbody><tr style='height: 0.15in; mso-yfti-irow: 0; mso-yfti-firstrow: yes'><td valign='top' width='295' style='border-right:windowtext 1pt solid; padding-right: 5.4pt; border-top: windowtext 1pt solid; padding-left: 5.4pt; padding-bottom: 0in; border-left:windowtext 1pt solid; width: 221.5pt; padding-top: 0in; border-bottom: windowtext 1pt solid; height: 0.15in; background-color: transparent; mso-border-alt: solid windowtext .5pt'><p class='MsoNormal' align='right' style='margin: 0in 0in 0pt; text-align: right'><span style='font-size: 8pt; font-family: Verdana'><o:p></o:p></span></p></td><td valign='top' width='295' style='border-right: windowtext 1pt solid; padding-right: 5.4pt;border-top: windowtext 1pt solid; padding-left: 5.4pt; padding-bottom: 0in; border-left: #d4d0c8; width: 221.3pt; padding-top: 0in; border-bottom: windowtext 1pt solid; height: 0.15in; background-color: transparent; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt'><p class='MsoNormal' style='margin: 0in 0in 0pt'><span style='font-size: 8pt; font-family: Verdana'><o:p></o:p></span></p></td></tr><tr style='height: 0.15in; mso-yfti-irow: 1'><td valign='top' width='295' style='border-right: windowtext 1pt solid; padding-right: 5.4pt; border-top: #d4d0c8; padding-left: 5.4pt;padding-bottom: 0in; border-left: windowtext 1pt solid; width: 221.5pt; padding-top: 0in; border-bottom: windowtext 1pt solid; height: 0.15in; background-color: transparent; mso-border-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt'><p class='MsoNormal' align='right' style='margin: 0in 0in 0pt; text-align: right'><span style='font-size: 8pt; font-family: Verdana'><o:p></o:p></span></p></td><td valign='top' width='295' style='border-right: windowtext 1pt solid; padding-right: 5.4pt; border-top: #d4d0c8; padding-left: 5.4pt; padding-bottom: 0in; border-left: #d4d0c8; width: 221.3pt; padding-top: 0in; border-bottom: windowtext 1pt solid; height: 0.15in; background-color: transparent; mso-border-alt: solid windowtext .5pt; mso-border-left-alt: solid windowtext .5pt; mso-border-top-alt: solid windowtext .5pt'><p class='MsoNormal' style='margin: 0in 0in 0pt'><span style='font-size: 8pt; font-family: Verdana'>";
    //This yields "Submitted&nbsp;"
    yourHTML = RemoveHtml(yourHTML);

    I can't think of why it wouldn't be working. Have you tried placing a breakpoint within your code and checking through it as it executes to see where it may be going wrong?

    Monday, April 15, 2013 8:12 PM
  • User-2019470928 posted
    /* Microsoft SQL Server Integration Services Script Component
    *  Write scripts using Microsoft Visual C# 2008.
    *  ScriptMain is the entry point class of the script.*/
    // C# code
    using System;
    using System.Data;
    using System.Text.RegularExpressions;    // Added
    using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
    using Microsoft.SqlServer.Dts.Runtime.Wrapper;
    
    [Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
    public class ScriptMain : UserComponent
    {
        // Method that will be executed for each row.
        public override void Input0_ProcessInputRow(Input0Buffer Row)
        {
              // Replace the value of the message column
            if (!string.IsNullOrEmpty(Row.Notes))
            {
                string strRowNotes = RemoveHtml(Row.Notes);
                if (!string.IsNullOrEmpty(strRowNotes))
                {
                    // Replace the value of the message column
                    Row.Notes = RemoveHtml(Row.Notes)
                        .Replace("&nbsp;", " ")
                        .Replace("&amp;", " ").Replace("-->", " ").Replace("&quot;", "\"")
                        .Replace("&lt;", "<")
                        .Replace(": YES", ": YES ").Replace(": NO", ": NO ")
                        .Replace("<p class=\"MsoNormal \"", " ")
                       .Replace("<table cellspacing=", " ")
                        ;
                }
                else
                    Row.Notes = "";
            }
            else
                Row.Notes = "";      
           
        }
    
        // A string method that removes html tags
        // with a regex pattern
        public String RemoveHtml(String message)
        {
            // The pattern for a html tag
    
            String htmlTagPattern = @"<[^\>]*>";
                //"<([^\n>]*)>";
                ///"<(.|\n=)*?>";
           // string htmlTagPattern = "/(<[^\n]+)[^>]*(>)/?>";
                ///"/(<[^\n]+)[^>]*(>)/";
            /// ///"<(.|\n)*?>"
            /// ///<[^>]*>
          // String htmlTagPattern = "<(.|\n)*?>";
            /// ///"(?<=<[^>]*)&nbsp"
            // Create a regex object with the pattern 
            Regex objRegExp = new Regex(htmlTagPattern);
            // Replace html tag by an empty string
    
            message = objRegExp.Replace(message, String.Empty);
            
            // Return the message without html tags
            return message;
    
                }
    }
    

    Please let me know if im doing something incorrect in the code, the same code is putting out empty spaces for the above pattern,

    Monday, April 15, 2013 8:50 PM
  • User281315223 posted

    The code appears correct.

    What exactly is being outputted? Is it the emptry string or something else? Are you able to debug this code at all, as using a breakpoint would allow you to check the values as it executes to determine where things are going wrong.

    Have you tried removing the additional Replace calls to see if that makes any difference at all?

    string strRowNotes = RemoveHtml(Row.Notes);
    if (!string.IsNullOrEmpty(strRowNotes))
    {
              // Remove additional Replace calls for debugging purposes
              Row.Notes = strRowNotes;
    }
    

    Monday, April 15, 2013 11:13 PM
  • User1508394307 posted

    There are few things to check

    • if html text includes line breaks then RemoveHtml() will return line breaks too, and this is where you might see some "empty spaces". You can remove "\r\n" using string.Replace() if required.
    • doing .Replace("<table cellspacing=", " "), and .Replace("<p class=\"MsoNormal \"", " ") is not required as you already called RemoveHtml() where all <tags> have been removed
    • html decoding such as .Replace("&nbsp;", " ") can be done using System.Web.HttpUtility.HtmlDecode()
    • bloat coding
      string strRowNotes = RemoveHtml(Row.Notes);
      if (!string.IsNullOrEmpty(strRowNotes)){
      Row.Notes = RemoveHtml(Row.Notes)
    Tuesday, April 16, 2013 3:00 AM
  • User-2019470928 posted
    Hi All- the below format is also putting out empty spaces " ", can i clean this or is there a way to put out the source value in the else statement , I'll paste the C# code,
    /* Microsoft SQL Server Integration Services Script Component
    *  Write scripts using Microsoft Visual C# 2008.
    *  ScriptMain is the entry point class of the script.*/
    // C# code
    using System;
    using System.Data;
    using System.Text.RegularExpressions;    // Added
    using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
    using Microsoft.SqlServer.Dts.Runtime.Wrapper;
    using System.Web;
    [Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
    public class ScriptMain : UserComponent
    {
        // Method that will be executed for each row.
        public override void Input0_ProcessInputRow(Input0Buffer Row)
        {
              // Replace the value of the message column
            if (!string.IsNullOrEmpty(Row.Notes))
            {
                //string strRowNotes = RemoveHtml(Row.Notes);
                //if (!string.IsNullOrEmpty(strRowNotes))
                //{
                //    // Replace the value of the message column
                    Row.Notes = RemoveHtml(Row.Notes)
                        .Replace("&nbsp;", " ")
                        .Replace("&amp;", " ").Replace("-->", " ").Replace("&quot;", "\"")
                        .Replace("&lt;", "<")
                        .Replace(": YES", ": YES ").Replace(": NO", ": NO ")
                       .Replace("\r\n", "")
                       //.Replace("<table cellspacing=", " ")
                        ;
                }
               else
                     Row.Notes=Row.Notes ;
              
           
        }
    
        // A string method that removes html tags
        // with a regex pattern
        public String RemoveHtml(String message)
        {
            // The pattern for a html tag
    
            String htmlTagPattern = @"<[^\>]*>";
                //"<([^\n>]*)>";
                ///"<(.|\n=)*?>";
           // string htmlTagPattern = "/(<[^\n]+)[^>]*(>)/?>";
                ///"/(<[^\n]+)[^>]*(>)/";
            /// ///"<(.|\n)*?>"
            /// ///<[^>]*>
          // String htmlTagPattern = "<(.|\n)*?>";
            /// ///"(?<=<[^>]*)&nbsp"
            // Create a regex object with the pattern 
            Regex objRegExp = new Regex(htmlTagPattern);
            // Replace html tag by an empty string
    
            message = objRegExp.Replace(message, String.Empty);
            
            // Return the message without html tags
            return message;
    
                }
    }
    
    
    
     - <div><b>This is Sample a&nbsp;&nbsp;&nbsp;
     Item 1</b></div><div>&nbsp;</div><div><b>Date : &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
     ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3/31/11&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
     ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;</b></div><div><b>
     Cause :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
     ;Wind&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></div><div><b>Loss Location: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;60 Gulf Blvd.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
     ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
     Indian Rocks Beach, Fl 33785&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></div><div><b>Policy Type:
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
      ;Wind&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      &nbsp;</b></div><div><b>Policy Dates: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      &nbsp;&nbsp;&nbsp;10/26/10-11&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      &nbsp;&nbsp;&nbsp; &nbsp;</b></div><div><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
       Within policy term </b></div><div><b>:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
       ;&nbsp;CIT CR2 (01-10) CRW 01 10 (01-10) CIT 33 23 (01-06)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
       </b></div><div><b> </b></div><div><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$&nbsp; 30,000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </b></div><div><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
       Contents: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; na</b></div><div><b>Estimated damages&nbsp;</b></div><div><b>
       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;$ 18,500&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;
       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </b></div><div><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
       Contents:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; na</b></div><div><b>Ded:&nbsp;&nbsp;&nbsp;
       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $ 1,000<br /><br />Structure&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
       &nbsp;&nbsp;</b><b>&nbsp;&nbsp;&nbsp;&nbsp;$ 10,700&nbsp;&nbsp;&nbsp;&nbsp;
       Will need increase  estimate&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </b></div><div><b>&nbsp;&nbsp;
       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LAE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;Incl.&nbsp;&nbsp;&nbsp; &nbsp;</b></div><div><b>&nbsp;&nbsp;&nbsp;&nbsp
       ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; No</b>
       </div><div><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;No</b>
       </div><div><b>SI:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
       ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;No</b></div><div><b>Experts &nbsp;&nbsp;
       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
       ;&nbsp; &nbsp;No</b></div><div><b>Publics &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;No </b></div><div><b>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; none listed</b></div>
       <div><b>Coverage &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp
       ;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; covered cause </b></div><div><b>&nbsp;</b></div><div><b>&nbsp;</b>
    </div><div>&nbsp;</div><div>GD X4110</div>

    Tuesday, April 16, 2013 12:09 PM
  • User281315223 posted

    If the input is the same as the code that you just provided (the massive block of &nbsp; ) and you want to strip out everything but the actual words (so remove all of the HTML tags and all of the instances of &nbsp;) then the following Regular Expression should match both of those : 

    <[^>]*>|&nbsp;

    It will match any HTML tag and explicitly any &nbsp; so that you can remove them within your RemoveHtml method : 

    public string RemoveHtml(String message)
    {
            // Your Pattern to strip all HTML and &nbsp;
            string htmlTagPattern = @"<[^\>]*>|&nbsp;";
            
            // Create a regex object with the pattern 
            Regex objRegExp = new Regex(htmlTagPattern);
            
            // Replace html tag by an empty string
            message = objRegExp.Replace(message, String.Empty);
            
            // Return the message without html tags
            return message;
    }

    However, the previous code that you were using (to initially strip all of the HTML tags) and then use the chained Replace statements should have handled this for you.

    Have you placed a breakpoint within this code (if possible) to see if you can determine where the problem is occuring at?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 16, 2013 12:56 PM
  • User1508394307 posted

    jampa09

    Hi All- the below format is also putting out empty spaces " ", can i clean this

    myString = Regex.Replace(myString, @"\s+", " ");
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 16, 2013 3:02 PM
  • User-2019470928 posted

    Rion,

    Thank you very much for all your help and time. the code finally worked . I appreciate your support 

    Thanks !!!

    Wednesday, April 17, 2013 1:55 PM
  • User-2019470928 posted

    Smirnov,

    Thank you very much for all your help and time. the code finally worked . I appreciate your support 

    Thanks !!!

    Wednesday, April 17, 2013 1:57 PM