![]() |
Delphi-Version: 2010
Char from set in string?
Delphi-Quellcode:
const
ParamSeps = ['=', ':', '?'];
Delphi-Quellcode:
Is possible to check if char is in text using above set instead if-block and Pos()?
P := Pos('=', AIn);
if P = 0 then begin P := Pos(':', AIn); if P = 0 then P := Pos('?', AIn) ; end; |
AW: Char from set in string?
An other way might be
Delphi-Quellcode:
K-H
i:=0;
repeat inc(i,1); until (i>length(aIn)) or (aIn[i] in ParamSeps); if I>length(aIn) then //sepchar found |
AW: Char from set in string?
Delphi-Quellcode:
const
ParamSeps = ['=', ':', '?']; Function SetCharPos(Const s:String):Integer; var i:Integer; begin Result := 0; i := 1; while (Result=0) and (i<=Length(s)) do begin if s[i] in ParamSeps then Result := i else inc(i); end; end; procedure TForm1.Button1Click(Sender: TObject); begin Caption := IntToStr(SetCharPos('That?')) end; |
Re: Char from set in string?
O, quite simple, thanks :)
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:06 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz