Didi.04-9-10 教师节
**function** SplitEx( **const** Str _{需要拆分的文章}_ , Delimiters _{拆分关键字,回车.?!等}_ : **string** ): TStringList;
**var**
ss: WideString;
i, St: integer;
**function** IsDelimiter( **const** Delimiters, c: **string** ): Boolean;
**begin** _//判断是否为拆分关键字_ result := StrScan(PChar(Delimiters), c[1]) <> **nil** ;
**end** ;
**begin**
Result := TStringList.Create;
**with** Result **do**
**begin**
Clear; Sorted := True; Duplicates := dupIgnore;
**end** ;
**if** Length(Str) < 1 **then** exit;
ss := Str; _//双字符支持,纯英文可以去掉_ St := -1;
**for** i := 1 **to** Length(ss) **do**
**if** IsDelimiter(Delimiters, ss[i]) **then**
**if** St <> -1 **then**
**begin**
Result.Add(Trim(Copy(ss, St, i - St)));
St := -1;
**end**
**else**
**if** St = -1 **then** St := i;
**if** St <> -1 **then** Result.Add(Copy(ss, St, Length(Str)));
**end** ;
_//操作演示_ **with** SplitEx(Memo1.Text, ',,. ?! ' + #13#10) **do**
**try**
SaveToFile('c:\temp_demo.txt');
**finally**
Free;
**end** ;
原帖 http://community.csdn.net/Expert/topic/3357/3357097.xml?temp=.9228937