delphi的分离字符串函数split-Delphi编程
2008-06-18 17:28
323 查看
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type userarray=array of string;
type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
function split(s: string; dot: char): userarray;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses StrUtils;
{$R *.dfm}
function TForm1.split(s:string;dot:char):userarray;
var
str:userarray;
i,j:integer;
begin
i:=1;
j:=0;
SetLength(str, 255);
while Pos(dot, s) > 0 do
begin
str[j]:=copy(s,i,pos(dot,s)-i);
i:=pos(dot,s) 1;
s[i-1] := chr(ord(dot) 1);
j:=j 1;
end;
str[j]:=copy(s,i,strlen(pchar(s))-i 1);
result:=str;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
ur:userarray;
i:Integer;
begin
ur:=split(Edit1.Text,';');
for i :=0 to 255 do
begin
if length(ur[i])=0 then Exit;
ShowMessage(ur[i]);
end;
end;
end.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type userarray=array of string;
type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
function split(s: string; dot: char): userarray;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses StrUtils;
{$R *.dfm}
function TForm1.split(s:string;dot:char):userarray;
var
str:userarray;
i,j:integer;
begin
i:=1;
j:=0;
SetLength(str, 255);
while Pos(dot, s) > 0 do
begin
str[j]:=copy(s,i,pos(dot,s)-i);
i:=pos(dot,s) 1;
s[i-1] := chr(ord(dot) 1);
j:=j 1;
end;
str[j]:=copy(s,i,strlen(pchar(s))-i 1);
result:=str;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
ur:userarray;
i:Integer;
begin
ur:=split(Edit1.Text,';');
for i :=0 to 255 do
begin
if length(ur[i])=0 then Exit;
ShowMessage(ur[i]);
end;
end;
end.
相关文章推荐
- delphi 的分离字符串函数 split
- [导入]delphi 的分离字符串函数 split
- C# 对字符串进行分离 split 字符串分割 "aaaa---bbbb---ccc"方法
- ASP中Split分割字符串函数的实例用法
- .net C# listbox的key和Text分离,类似delphi的listbox的Data
- 【OpenCV3】图像通道分离与合并——cv::split()与cv::merge()详解
- javascript 中几个常用的字符串函数(split()、join()、substring()、indexof())
- sqlserver中实现split分割字符串函数常用的
- Delphi制作客户端系统功能组件分离的架构设计
- Delphi字符串函数大全
- SQL里类似SPLIT的分割字符串函数
- Delphi字符串函数Delete
- Opencv中颜色通道分离、混合的split和merge
- Delphi字符串函数大全
- opencv学习笔记-split分离和merge合并操作
- SQL里类似SPLIT的分割字符串函数
- Delphi中实现界面与业务逻辑的分离
- [SqlServer]数据库中自定义拆分字符串函数Split()
- sql2008里自定义SPLIT分隔字符串函数
- Delphi 正则表达式TPerlRegEx : Split 函数