Frequently Used string functions

Source: Internet
Author: User
Function quotedstr (const S: string): string; $ [sysutils. Pas
Returns the expression of string s in Pascal.
It indicates that one of the single quotes will be converted into two
See procedure system. insert
Example edit2.text: = quotedstr (edit1.text );
When there are too many threads, there are too many threads, too many threads.
Function ansiquotedstr (const S: string; quote: Char): string; $ [sysutils. Pas
Function returns the expression of string s in quotation marks
Description: ansiquotedstr ('Hello "world', '@') = '@ hello" World @'; ansiquotedstr ('Hello "world ','"') = '"hello" "world "'
Refer to function sysutils. ansistrscan
Example edit2.text: = ansiquotedstr (edit1.text ,'"');
When there are too many threads, there are too many threads, too many threads.
Function ifthen (avalue: Boolean; const atrue: string; afalse: String = ''): string; overload; $ [strutils. Pas
Function returns the specified logical string
Ifthen (true, 'yes', 'no') = 'yes'; ifthen (false, 'yes', 'no') = 'no'
See <null>
Example edit3.text: = ifthen (checkbox1.checked, edit1.text, edit2.text );
When there are too many threads, there are too many threads, too many threads.
First function leftstr (const atext: string; const acount: integer): string; $ [strutils. Pas
Function returns the acount characters on the left of the atext string.
Description leftstr ('20140901', 3) = '20160901'
Refer to function system. Copy
Example edit3.text: = leftstr (edit1.text, spinedit1.value );
When there are too many threads, there are too many threads, too many threads.
First function rightstr (const atext: string; const acount: integer): string; $ [strutils. Pas
Function returns the acount characters on the right of the atext string.
Description: rightstr ('20140901', 3) = '20160901'
Refer to function system. Copy
Example edit3.text: = rightstr (edit1.text, spinedit1.value );
When there are too many threads, there are too many threads, too many threads.
First function midstr (const atext: string; const astart, acount: integer): string; $ [strutils. Pas
Returns the acount characters starting with astart.
It means copy.
Refer to function system. Copy
Example edit3.text: = midstr (edit1.text, spinedit1.value, spinedit2.value );

When there are too many threads, there are too many threads, too many threads.
Function ansimatchstr (const atext: string; const avalues: array of string): Boolean; $ [strutils. Pas
Function returns whether the avalues array contains the atext string.
Case Sensitive
Refer to function strutils. ansiindexstr
Example: checkbox1.checked: = ansimatchstr (edit1.text, ['a1', 'a2 ', 'a3', 'a4']);
When there are too many threads, there are too many threads, too many threads.
First function ansiindexstr (const atext: string; const avalues: array of string): integer; $ [strutils. Pas
Returns the position of the string atext in the string array avalues.
Case Sensitive
Refer to function sysutils. ansisamestr
Example: spinedit1.value: = ansiindexstr (edit1.text, ['a1', 'a2 ', 'a3', 'a4 ']);
When there are too many threads, there are too many threads, too many threads.
First function dupestring (const atext: string; acount: integer): string; $ [strutils. Pas
Returns the acount duplicate of the atext string.
Indicates that ''is returned when acount is 0''
Refer to function system. setlength
Example edit3.text: = dupestring (edit1.text, spinedit1.value );
When there are too many threads, there are too many threads, too many threads.
First function reversestring (const atext: string): string; $ [strutils. Pas
Returns the reverse order of the string atext.
Description reversestring ('20140901') = '20160901'
Refer to function system. setlength
Example edit3.text: = reversestring (edit1.text );
When there are too many threads, there are too many threads, too many threads.
First function stuffstring (const atext: string; astart, alength: Cardinal; const asubtext: string): string; $ [strutils. Pas
Function returns nested strings
Description: astart: nesting start position; alength: Nested length; stuffstring ('abcd', 2, 0, '12') = 'a12bcd'
Refer to function system. Copy
Example edit3.text: = stuffstring (edit1.text, spinedit1.value, spinedit2.value, edit2.text );
When there are too many threads, there are too many threads, too many threads.
First function randomfrom (const avalues: array of string): string; overload; $ [strutils. Pas
Function returns an element of the string array avalues at random.
Randomize is recommended.
Refer to function system. Random
Example randomize; edit3.text: = randomfrom (['a1', 'a2 ', 'a3', 'a4 ']);
When there are too many threads, there are too many threads, too many threads.
Function adjustlinebreaks (const S: string; style: ttextlinebreakstyle ={$ ifdef Linux} tlbslf {$ endif }{$ ifdef mswindows} tlbscrlf {$ endif}): string; $ [sysutils. PAS
Function returns the line delimiter of the given string to the CR/LF sequence.
Description: adjustlinebreaks ('1' #13 '2' #13) = '1' #13 #10 '2' #13 #10; adjustlinebreaks ('1' # 10' 2' #10) = '1' #13 # 10' 2' #13 #10
Refer to function sysutils. strnextchar

too many parameters have been written before using the function Format (const format: string; const ARGs: array of const): string; $ [sysutils. the PAS
function returns the character format of formatting an array constant in the specified way.
this function is the most used function in Delphi, here are a few examples to give you an intuitive understanding
"%" [Index ":"] ["-"] [width] [". "Abstract] type
Format ('X = % d', [12]); // 'X = 12' // The most common
Format ('X = % 3d ', [12]); // 'X = 12' // specify the width
Format ('X = % F', [12.0]); // 'X = 12.00 '// floating point number
Format ('X = %. 3f', [12.0]); // 'X = 100' // specify the decimal point
Format ('X = %. * F', [5, 12.0]); // 'X = 100' // dynamic configuration
Format ('X = %. 5D ', [12]); // 'X = 100' // Add 0
Format ('X = %. 5x ', [12]); // 'X = 20.c' // hexadecimal
Format ('X = % 1: d % 0: d ', [12, 13]); // 'X = 100' // use the index
Format ('X = % P', [nil]); // 'X = 100' // pointer
Format ('X = % 1.1e ', [00000000]); // 'X = 1.2e + 001' // scientific note
Format ('X = % ', []); // 'X = % '// get "%"
S: = format (' % S % d', [s, I]); // S: = S + strtoint (I); // connection string
refer to proceduer sysutils. fmtstr
example edit1.text: = format (edit2.text, [strtofloatdef (edit.3.text, 0)]);

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.