{從字符串中提取單詞的函數}
procedure StrToWordList(str: string; var List: TStringList); var
p: PChar;
i: Integer;
begin
if List = nil then List := TStringList
List
{去除重復}
List
List
p := PChar(str);
{把單詞以外的字符轉為空格
while p^ <> #
begin
case p^ of
else p^ := #
end;
Inc(p);
end;
{用空格分離單詞到列表}
List
List
{單詞的開頭應該是字母
for i := List
begin
if CharInSet(List[i][
List
end;
end;
{從字符串中提取漢字的函數}
procedure StrToHanZiList(str: string; var List: TStringList);
var
p: PWideChar;
begin
if List = nil then List := TStringList
List
{去除重復}
List
List
p := PWideChar(str);
while p^ <> #
begin
case p^ of
#$
end;
Inc(p);
end;
end;
From:http://tw.wingwit.com/Article/program/Delphi/201311/8389.html