 |
操作系统: WindowsXp
编程工具: Delphi7
问题: 如何分离一行文字?
比如
1234$abcd$xyz
我只知道VB可以用Split(s,'$')。请问使用Delphi能做到吗?
水平: 刚入门(Mac)
|
| |
|
 |
Delphi有一个ExtractStrings函数。该函数定义为:
type TSysCharSet = set of Char;
function ExtractStrings(Separators, WhiteSpace: TSysCharSet; Content: PChar; Strings: TStrings): Integer;
Separators是分割符号的集合,而WhiteSpace是表示空格的集合。该函数按照分割符号分割字符串。
对于你的例子,可以这样:
ExtractStrings(['$'], [' '],
'1234$abcd$xyz', memo1.Lines);
另外,再提供一个例子:
ExtractStrings([DateSeparator], [' '],
PChar(DateToStr(Now)), memo1.Lines);
此问题由李海回答。
附加关键字:编程, 源程序, programming, source code, Delphi, VCL, Borland, 其他方面, 。
|
| |
|
| |
|
| |
|
|