All company profiles in the database are saved from the text editor. Of course, the style is also saved to the database. What should I do if I only want to get the text content?
Code
# Region Filter HTML
/// <Summary>
/// Filter HTML tags
/// </Summary>
/// <Param name = "strhtml"> HTML content </Param>
/// <Returns> </returns>
Public Static String Striphtml ( String Strhtml)
{
String [] Aryreg = {
@" <SCRIPT [^>] *?>. *? </SCRIPT> " ,
@" <(\/\ S *)?!? (\ W + :)? \ W +) (\ W + (\ s * =? \ S * (["" ']) (\ ["" 'tbnr] | [^ \ 7]) *? \ 7 | \ W +) |. {0}) | \ s )*? (\/\ S *)?> " ,
@" ([\ R \ n]) [\ s] + " ,
@" & (Quot | #34 ); " ,
@" & (Amp | #38 ); " ,
@" & (LT | #60 ); " ,
@" & (GT | #62 ); " ,
@" & Amp; (nbsp | #160 ); " ,
@" & (Iexcl | #161 ); " ,
@" & (Cent | #162 ); " ,
@" & (Pound | #163 ); " ,
@" & (Copy | #169 ); " ,
@" & # (\ D + ); " ,
@" --> " ,
@" <! --. * \ N "
};
String [] Aryrep = {
"" ,
"" ,
"" ,
" \ "" ,
" & " ,
" < " ,
" > " ,
" " ,
" \ XA1 " , // CHR (1, 161 ),
" \ Xa2 " , // CHR (1, 162 ),
" \ Xa3 " , // CHR (1, 163 ),
" \ Xa9 " , // CHR (1, 169 ),
"" ,
" \ R \ n " ,
""
};
String Newreg = Aryreg [ 0 ];
String Stroutput = Strhtml;
For ( Int I = 0 ; I < Aryreg. length; I ++ )
{
System. Text. regularexpressions. RegEx = New System. Text. regularexpressions. RegEx (aryreg [I], system. Text. regularexpressions. regexoptions. ignorecase );
Stroutput = RegEx. Replace (stroutput, aryrep [I]);
}
Stroutput. Replace ( " < " , "" );
Stroutput. Replace ( " > " , "" );
Stroutput. Replace ( " \ R \ n " , "" );
Return Stroutput;
}
# Endregion