Delphi分割字符串的函数
来源:互联网 发布:运动软件推广方案 编辑:程序博客网 时间:2024/05/01 02:52
Unit Classes
Syntax
[Delphi] function ExtractStrings(Separators: TSysCharSet; WhiteSpace: TSysCharSet; Content: PAnsiChar; Strings: TStrings): Integer;
Description Use ExtractStrings to fill a string list with the substrings of the null-terminated string specified by Content.
Separators is a set of characters that are used as delimiters, separating the substrings. Carriage returns, newline characters, and quote characters (single or double) are always treated as separators. Separators are ignored when inside a quoted string until the final end quote. (Note that quoted characters can appear in a quoted string if the quote character is doubled.)
WhiteSpace is a set of characters to be ignored when parsing Content if they occur at the beginning of a string.
Content is the null-terminated string to parse into substrings.
Strings is a string list to which all substrings parsed from Content are added. The string list is not cleared by ExtractStrings, so any strings already in the string list are preserved. ExtractStrings returns the number of strings added to the Strings parameter. Note:
ExtractStrings does not add empty strings to the list.
[update]:
Separators 参数指定一组分割符,所有的子串都是用它们分割的。但是成对的引号内的分割符会被忽略(参看下面的例子)。
WhiteSpace 参数指定每个子串开头被忽略的字符s。
Content 参数就是被分割的“源”串了。
Strings 参数用于接收分割后的各个子串。它的原有内容不会被清空。别忘了Create哦。
另外,EctractStrings不会把(忽略WhiteSpaces后的)空串加入到Strings中。
写个例子吧:
比如
ABC|... DEF|#### GHI|"不会被分开|# www.farproc.com"
要得到
ABC
DEF
GHI
不会被分开|# www.farproc.com
四个子串可以用下面的代码:
uses
Classes;
var
ASource: PChar;
AStr: String;
ACount: Integer;
AStrings: TStringList;
begin
ASource := 'ABC|... DEF|#### GHI|"不会被分开|# www.farproc.com"';
AStrings := TStringList.Create;
try
ACount := ExtractStrings(['|'], [' ', '#', '.'], ASource, AStrings);
{do any further processing}
/for AStr in AStrings do
// Writeln(AStr);
finally
AStrings.Free;
end;
Readln;
end.
- Delphi分割字符串的函数
- Delphi分割字符串的函数
- DELPHI字符串分割函数
- Delphi字符串分割函数
- DELPHI中优秀的字符串分割函数
- [update]Delphi分割字符串的函数 ExtractStrings
- Delphi中优秀的字符串分割函数
- Delphi分割字符串的函数--ExtractStrings
- Delphi分割字符串的函数ExtractStrings
- Delphi中优秀的字符串分割函数
- Delphi中的一些字符串分割的函数收集
- Delphi 自带的字符串分割函数split
- Delphi自带的字符串分割函数Split
- delphi 中 字符串分割函数 ExtractStringsEx,是ExtractStrings函数的扩展
- Delphi中stringlist分割字符串的用法
- DELPHI 字符串分割处理
- DELPHI 字符串分割处理
- delphi字符串分割
- 什么是社会工程学?剖析社会工程学的心理状况
- 5.09总结
- 中国的软件人员为什么急功近利?
- 关于IMS服务更新、创建
- 终于成为csdn的注册会员了!
- Delphi分割字符串的函数
- 开始
- 公务员考试——申论3
- jdbc连接各种数据库方式列表
- ajax技术 vs 传统的asp无刷新技术.(转)
- 初次登陆
- 中华人民共和国著作权法
- ORACLE 常用的SQL语法和数据对象
- IP认证计费系统维护基础知识