The use of Copy,delete,pos and Leftstr,rightstr in Delphi

Source: Internet
Author: User

Copy

For example: str: = "123456"; str1: = Copy (str,2,3); As a result str1 equals 234. Copy has 3 parameters, the first is the string you want to handle, the second is the start position you want to intercept, and the 3rd is the number of bits to intercept. When your 3rd argument is greater than the character length, the effect is to take all the characters from the start position. STR1: = Copy (str,2,10); The result is that str1 equals 23456.

Leftstr and POS

Suppose the string is S: = ' Delphi is the best ', then
Leftstr (S, 5): = ' Delph '//s first 5 characters
Midstr (S, 6, 7): = ' i-is-th '//That is, the sixth bit of S starts after 7 characters (-:= spaces)
Rightstr (S, 6): = ' e-best '//is the character after S (-:= space)

Remove the first occurrence of a substring in the parent string
For example
POS (' B ', ' ABCD ');
The return result is 2//pos, which is the display B in the entire character.


Delete

Liezi:

Var
s:string;
Begin
S: = ' 12345 ';
Delete (S, 2, 2);
ShowMessage (S);//display 145 deletes 23. That is, delete the second bit of S from the beginning of the 2 characters.
End

The use of Copy,delete,pos and Leftstr,rightstr in Delphi

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.