有人寫過html to txt的程式嗎 |
答題得分者是:qoo1234
|
ks0741
一般會員 發表:11 回覆:5 積分:3 註冊:2003-03-29 發送簡訊給我 |
|
Windyboy
版主 發表:7 回覆:119 積分:210 註冊:2002-11-07 發送簡訊給我 |
|
qoo1234
版主 發表:256 回覆:1167 積分:659 註冊:2003-02-24 發送簡訊給我 |
|
qoo1234
版主 發表:256 回覆:1167 積分:659 註冊:2003-02-24 發送簡訊給我 |
另一種寫法:
!************************************** ! for :easy html stripping !************************************** If you read and understand it before you use it, feel free to do so. If you just copy paste it and delete all my comments, I will kill you :p !************************************** ! Name: easy html stripping ! Description:It's just a function that takes a string, and takes out anything between <>'s. This can be used as a html stripper ! By: Willem Wollebrants ! ! ! Inputs:strip(string_with_html_tags) ! ! Returns:string_without_html_tags! ! !Assumes:None ! !Side Effects:none that I know of !This code is copyrighted and has limited warranties. !Please see http://www.1PHPStreet.com/xq/ASP/txtCodeId.1155/lngWId.7/qx/vb/scripts/ShowCode.htm !for details. !************************************** //------------------------------------------------------- // Author: Willem Wollebrants (willemwollebrants@hotmail.com) // Date : June 11, 2003 // What it does : Takes a string, then strips any text between <>'s //(html tag stripper really // Notes: It's the first code I release. Hope it helps you //Don't just copy paste, try to understand how it works. //------------------------------------------------------- function strip(shtml: string ): string; //shtml is the string with the html code we want to strip var HPos, Len: integer; //Hpos will store where our html tag starts //Len is the length of the tag begin //find the first < in the string HPos := Pos( '<', shtml ); //now get the distance to the first >, this gives us the length Len := Pos( '>', shtml ) - Pos( '<', shtml ) 1; //the 1 is a correction for the fact that pos() counts 0,1,2, //so we need to add 1 to get it right (or our > maybe left standing there) while(nHPos > 0)do //while we still can find < in the string begin //delete the tag Delete( shtml, nHPos, nLen ); //insert an empty space, a bit obsolete //but can be usefull if you want to replace the tags by other text Insert( '', shtml, nHPos ); //check for other < nHPos := Pos( '<', shtml ); //and set the length again nLen := Pos( '>', shtml ) - Pos( '<', shtml ) 1; end; //finally give us the result Result := shtml; end; //usage: text1.text = strip(<html>Hi everybody</html>)網海無涯,學無止境! |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |