In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how delphi encapsulates several functions of getting substrings". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "delphi how to encapsulate a few functions to get the substring"!
Preface
Unlike the advanced version or C# or JAVA, there are special methods for string manipulation in delphi7, so sometimes we need to make some functions and put them in the common unit for calling. Here are several functions for intercepting strings, which can be used directly.
Function code
Intercept some characters in a string
StrSource: source string
StrBegin: start position string
StrEnd: end position string
Example: GetStr ('abcd1234','bc','34') return value:' d12'
Function GetStr (StrSource, StrBegin, StrEnd: string): string
Var
In_star,in_end:integer
Begin
In_star:=AnsiPos (strbegin,strsource) + length (strbegin)
In_end:=AnsiPos (strend,strsource)
Result:=copy (strsource,in_star,in_end-in_star)
End
Intercept some characters in a string
StrSource: source string
StrBegin: start position string
StrEnd: end position string
Example: GetStrAll ('abcd1234','bc','34') return value:' bcd1234'
Function GetStrAll (StrSource, StrBegin, StrEnd: string): string
Var
In_star,in_end:integer
Begin
In_star:=AnsiPos (strbegin,strsource); / / + length (strbegin)
In_end:=AnsiPos (strend,strsource) + length (strend)
Result:=copy (strsource,in_star,in_end-in_star)
End
Intercept some characters in a string
StrSource: source string
StrBegin: start position
StrEnd: end position string
Example: GetStr ('abcd1234',1,'34') return value:' abcd12'
Function GetStrByIndex (StrSource:string; BeginIndex:integer;StrEnd: string): string
Var
In_star,in_end:integer
Begin
In_star:=BeginIndex
In_end:=AnsiPos (strend,strsource)
Result:=copy (strsource,in_star,in_end-in_star)
End
At this point, I believe you have a deeper understanding of "how to encapsulate several functions of substrings in delphi". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.