[英]Delete text before specific character in delphi
幫助我有很多字符串,我想在符號/之后保留字符串,它們就像:
63728/4817847 變成4817847 , 345/7895 變成7895 , 1289/98721 變成98721 , 1876789/987 變成987 。 我仍然沒有找到辦法,因為每次要存儲或刪除的字符串數量都在變化。 謝謝。
您可以使用Pos
和Copy
的組合輕松完成此操作。
Source := '1876789/987';
// Find position of `/` in the string
Index := Pos('/', Source);
if Index > 0 then
// Extract portion of string following the '/' (the + 1) to the end
Source := Copy(Source, Index + 1, Length(Source));
正如 SilverWarior 在評論中指出的那樣,您也可以使用System.Delete
。
Source := '1876789/987';
System.Delete(Source, 1, Pos('/', Source));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.