国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Delphi > 正文

截取指定符號之間的字符串(隨機讀取)delphi實例代碼

2020-01-31 20:51:52
字體:
供稿:網(wǎng)友

復(fù)制代碼 代碼如下:

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;

type
  TForm1 = class(TForm)
    test: TMemo;
    Button1: TButton;
    Memo1: TMemo;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

function   PosEx(const   Source,   Sub:   string;   Index:   integer):   integer;
var
   Buf                               :   string;
   i,   Len,   C                   :   integer;
begin
   C   :=   0;
   Result   :=   0;
   Buf   :=   Source;
   i   :=   Pos(Sub,   Source);
   Len   :=   Length(Sub);
   while   i   <>   0   do
   begin
       inc(C);
       Inc(Result,   i);
       Delete(Buf,   1,   i   +   Len   -   1);
       i   :=   Pos(Sub,   Buf);
       if   C   >=   Index   then   Break;
       if   i   >   0   then   Inc(Result,   Len   -   1);
   end;
   if   C   <   Index   then   Result   :=   0;
end;


procedure TForm1.Button1Click(Sender: TObject);
var
i,y:integer;
x,c:string;
g,g1:integer;
begin
 randomize;  //生成隨機數(shù)種子
            i:=random(30);
            y:=i+1;

 c:='topfox000|topfox001|topfox002|topfox003|topfox004|topfox005|topfox006|topfox0007|topfox008|topfox009|tellyoumysecret000|tellyoumysecret002|tellyoumysecret003|tellyoumysecret004|tellyoumysecret005|tellyoumysecret006|'+
'onhacker046|onionhacker047|onionhacker048|onionhacker049|onionhacker140|onionhacker141|onionhacker142|onionhacker143|onionhacker144';
 test.text:=test.text+inttostr(PosEx( c, '|',i));//返回5
  g:= PosEx( c, '|',i)+1;//返回5
test.text:=test.text+inttostr(PosEx( c, '|',y));//返回5
   g1:=PosEx( c, '|',y);//返回5
x:=Copy(c,g,g1-g);
memo1.text:=x;

end;

end.

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表

圖片精選

主站蜘蛛池模板: 红河县| 横峰县| 社旗县| 桃源县| 杨浦区| 六安市| 贵溪市| 若尔盖县| 新平| 名山县| 赞皇县| 财经| 德安县| 麻栗坡县| 大安市| 天全县| 海丰县| 姚安县| 资阳市| 东山县| 潞城市| 镇宁| 台山市| 文昌市| 滨海县| 喀喇| 醴陵市| 临江市| 凯里市| 淄博市| 兴仁县| 鄄城县| 离岛区| 辽阳市| 南漳县| 松江区| 兰考县| 健康| 宣汉县| 阿荣旗| 宁远县|