Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi extract string from string (https://www.delphipraxis.net/92492-extract-string-string.html)

mijack 21. Mai 2007 08:29


extract string from string
 
how can we extract Strings From String

myString :='Age:16'
+'Name:molley'
+'Country:Austria';

i want to extract the values of Age, Name , Country
edit1.text:=16;
edit2.text:=molley;
edit3.text:=Austria;

mkinzler 21. Mai 2007 08:35

Re: extract string from string
 
Pos()/PosEx() + Copy()
With a StringList (.DelimitedText)

marabu 21. Mai 2007 09:24

Re: extract string from string
 
Hi,

have a look at NameValueSeparator:

Delphi-Quellcode:
begin
  myString := 'Age:16' + sLineBreak + 'Name:molley' + sLineBreak + 'Country:Austria';
  with TStringList.Create do
  try
    Text := myString;
    NameValueSeparator := ':';
    edit1.text := Values['Age'];
    edit2.text := Values['Name'];
    edit3.text := Values['Country'];
  finally
    Free;
  end;
end;
Regards

MacGuyver 21. Mai 2007 09:28

Re: extract string from string
 
Hi,

it would work only, when you add #13 at the end of the lines.

myString :='Age:16' + #13
+'Name:molley' + #13
+'Country:Austria';

mkinzler 21. Mai 2007 09:31

Re: extract string from string
 
#13 is part of sLineBreak


Alle Zeitangaben in WEZ +1. Es ist jetzt 03:40 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz