Kênh 360 Công Nghệ Kênh 360 Công Nghệ

Trang chủ - Lập trình - Dot NET - Lọc thẻ HTML từ chuỗi

Lọc thẻ HTML từ chuỗi

 

Lọc thẻ HTML từ chuỗi, remove HTML tag từ string
  • 1 Remove HTML tags from a string using PHP with the following code:

    <?php $htmlstring = preg_replace("/<.*?>/", "", $htmlstring); ?>

    This method uses regular expressions to identify the start and end of any HTML tag and strip it from the string. Replace $htmlstring with whatever variable you use.

  • 2 Remove HTML tags from a string on ASP.net with the following code:

    { return Regex.Replace(text, @"<(.|\n)*?>", htmlstring.Empty); }

    As in the PHP version, replace "htmlstring" with whatever your string's variable is named.

  • 3 Remove HTML tags from a string using JavaScript if you run into problems with either of the above examples:

    function removeHTMLTags(htmlstring){
    if(htmlstring){
    var stringdiv = document.createElement("div");
    stringdiv.innerHTML = htmlstring;
    if(document.all) { return stringdiv.innerText; }
    else { return stringdiv.textContent; }
    } }

    Again, replace "htmlstring" with your string's variable.

Nguồn sưu tầm


Tin mới hơn:
Tin cũ hơn:

Lần cập nhật cuối ( Thứ tư, 17 Tháng 8 2011 09:25 )  

Kênh 360 công nghệ

  • Nổi bật
  • Tin mới
  • Game mới
  • PrestaShop Guide
  • PrestaShop

Có thể bạn quan tâm

Download nhiều nhất

11/12
Download PES 2011 - FIFA 11
693
18/12
binkw32 dll
175
18/12
TeamViewerQS
49
English French German Japanese Korean