![]() |
Nochmal RPos
Hallo Delphianer,
im Netz gibt es zahlreiche Lösungen für RPos. Eine ist fehlerhaft und andere sind lang und umständlich. Meine Lösung ist kurz: Voraussetzung keine leeren Strings und Hauptstring- >= Substring-Länge.
Delphi-Quellcode:
Mit PosEx aus StrUtils noch kürzer:
function RPos(const SubStr, Str: string): Integer;
begin Result:=0; if (SubStr <> '') and (Length(Str) - Length(SubStr) >= 0) then begin Result:=Length(Str) - Pred(Length(SubStr)); while (Copy(Str, Result, Length(SubStr)) <> SubStr) and (Result > 0) do Dec(Result); end; end;
Delphi-Quellcode:
Frage: Mein Delphi ist betagt, gibt es inzwischen RPos bei Delphi XE ?
uses StrUtils;
... function RPos(const SubStr, Str: string): Integer; begin Result:=0; if (SubStr <> '') and (Length(Str) - Length(SubStr) >= 0) then begin Result:=Length(Str) - Pred(Length(SubStr)); while (PosEx(Substr, Str, Result) = 0) and (Result > 0) do Dec(Result); end; end; Kennt jemand eine ASM-Lösung, das wäre doch etwas für einen Assembler-Programmierer. Schönen Sonntag Willie1. |
AW: Nochmal RPos
Warum suchst Du nicht rückwärts mit PChar?
|
AW: Nochmal RPos
Du könntest eines der folgenden verwenden
![]() ![]() ![]() |
AW: Nochmal RPos
Danke Freunde! W.
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:32 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