![]() |
Funktion die mir sagt, wie oft ein String vorkommt
Servus,
gibt es eine Funktion die mir sagt, wie oft ein String in einem anderen String vorkommt? |
Re: Funktion die mir sagt, wie oft ein String vorkommt
Pos bzw AnsiPos.
Edit: Ach Quatsch, ich sollte vielleicht genauer lesen :oops: Eine fertige Funktion gibt es bei Delphi meines Wissens nicht, aber du köntest ![]() Also irgendwie so:
Delphi-Quellcode:
var
str, substr: String; //str ist der String, substr der gesuchte Substring cnt, pos: Integer; begin cnt := 0; pos := NextPos(substr, str, pos); while pos > 0 do begin Inc(cnt); pos := NextPos(substr, str, pos); until; ShowMessage(InttoStr(cnt)); |
Re: Funktion die mir sagt, wie oft ein String vorkommt
Vielen Dank! Ich werds ausprobieren :)
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 08:37 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