Intercepts a string between specified symbols (random reads) Delphi Instance Code _delphi

Source: Internet
Author: User

Copy Code code as follows:

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 Generate random number of seeds
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));/return 5
G:= Posex (c, ' | ', i) +1;//return 5
Test.text:=test.text+inttostr (Posex (c, ' | ', y));/return 5
G1:=posex (c, ' | ', y);/return 5
X:=copy (C,G,G1-G);
Memo1.text:=x;

End

End.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.