delphi重写一个字符串分割函数


本文整理自网络,侵删。

 unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

{分割字符串的函数, 其实是个过程}
procedure Split(const str: string; const c: Char; var List: TStrings);
begin
List.Clear;
List.Delimiter := c;
List.DelimitedText := str;
end;

{调用测试}
procedure TForm1.Button1Click(Sender: TObject);
var
List: TStrings;
s: string;
c: Char;
begin
s := 'aaa;bbb;ccc;ddd';
c := ';';

List := TStringList.Create;
Split(s,c,List);
ShowMessage(List[1]); {bbb}
List.Free;
end;

end.

相关阅读 >>

Delphi 锁定鼠标移动范围

Delphi 字符串分割

Delphi xe(indy10)tidbytes转ansistring的实现

Delphi webbrowser用记事本查看源代码

Delphi 文件路径结尾去掉“\”

Delphi判断字符是否是汉字

Delphi2010 无法继承窗体的bug

使用Delphi启动和关闭外部应用程序

Delphi xe5 android 调用手机震动

Delphi代码直接注入别的进程

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...