![]() |
Von einem String vorne und hinten alle Leerzeichen entfernen
Hallo,
ich komme einfach nicht weiter.... Ich würde gerne alle Leerzeichen von einem String vorne und hinten löschen. Sprich aus dem (_ = Leerzeichen): Zitat:
Zitat:
Könnt Ihr mir helfen wie man soetwas machen kann? danke! |
Re: Von einem String vorne und hinten alle Leerzeichen entfe
mit der Funktion trim
Grüße Klaus |
Re: Von einem String vorne und hinten alle Leerzeichen entfe
Hello,
Try this:
Delphi-Quellcode:
Greets,
Function DeleteChar(strValue : String; aChar : Char) : String;
Var CharPos : Integer; Begin Repeat CharPos:=Pos(aChar,strValue); If CharPos<>0 Then Delete(strValue,CharPos,1); Until CharPos=0; Result:=strValue; End; Delphi-Lover. |
Re: Von einem String vorne und hinten alle Leerzeichen entfe
Zitat:
Your Code will also delete characters that are located in the String and not only the leading and trailing characters. Regards Klaus |
Re: Von einem String vorne und hinten alle Leerzeichen entfe
Hello Klaus,
Stimmt :-D , but to keep care of the characters in the string was not part of the question :lol: The trim function of your answer only deletes "space" characters and the control characters. Greetings, Delphi-Lover. |
Re: Von einem String vorne und hinten alle Leerzeichen entfe
Zitat:
that is perfectly done by trim :-) |
Re: Von einem String vorne und hinten alle Leerzeichen entfe
Zitat:
|
Re: Von einem String vorne und hinten alle Leerzeichen entfe
Hello,
Zitat:
Greets xaromz |
Re: Von einem String vorne und hinten alle Leerzeichen entfe
Hello,
Sorry, I read the question so that the problem was to delete the "_" characters. (underscore). Nothing about space or control chatcharaters. If you see my code it will delete those "_" characters and leave the space characters. Misunderstood the "_ = Leerzeichen". word. :cyclops: Could not believe it was about space characters what indeed can be solved by the trim function. Greets, Delphi-Lover. |
Re: Von einem String vorne und hinten alle Leerzeichen entfe
Dragon27 just uses then uderscores to visualize space characters as he wrote in this question (spaces = Leerzeichen)
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 05:12 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