. Net Automatically splits the text accepted by the label and filters out redundant or malicious characters.

Source: Internet
Author: User
Lbnr. Text = tourl (Dr ["remark"]. tostring (); // reference specific content displayed in the text of a control

/// <Summary>
/// Automatically split the text accepted by the label and filter out redundant or malicious characters
/// </Summary>
/// <Param name = "inputstring"> </param>
/// <Returns> </returns>
Public static string convertstr (string inputstring) // define
{
String retval = inputstring;
Retval = retval. Replace ("&", "& amp;"); // filter characters &
// Retval = retval. Replace ("\" "," & quot; "); // filter character \
// Retval = retval. Replace ("<", "& lt;"); // filter characters <
// Retval = retval. Replace (">", "& gt;"); // filter characters>
// Retval = retval. Replace ("", "& nbsp;"); // filter character spaces ""
// Retval = retval. Replace ("", "& nbsp;"); // filter the character """"
// Retval = retval. Replace ("\ t", "& nbsp;"); // filter character \ t
Retval = retval. Replace ("\ r", "<br>"); // filter character \ r <br>
Return retval;
}
Public static string tourl (string inputstring) // reference and replace
{
String retval = inputstring;
Retval = convertstr (retval );
Return retval;
// Retval = RegEx. Replace (retval, @ "\ [url] (? <X> [^ \] *) \ [/url] ", @ "<a href =" "$1" "target =" "_ blank" "> $1 </a>", regexoptions. ignorecase );
// Retval = RegEx. Replace (retval, @ "\ [Flash = (? <Width> \ D + ),(? <Height> \ D +)] (? <X> [^ \] *) \ [/flash] ", @ "<embed src =" "$3" "width =" "$ {width}" "Height =" "$ {height}"> </embed> ", regexoptions. ignorecase );
// Retval = RegEx. Replace (retval, @ "\ [Flash] (? <X> [^ \] *) \ [/flash] ", @" <embed src = "" $1 "> </embed>", regexoptions. ignorecase );
// Return RegEx. Replace (retval, @ "\ [img] (? <X> [^ \] *) \ [/img] ", @ "<a href =" "$1" "target =" "_ blank" "> screen. width-220) This. width = screen. width-220 "" border = 1> </a> ", regexoptions. ignorecase );
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.